curl-to-php icon indicating copy to clipboard operation
curl-to-php copied to clipboard

Your code don't convert Form Data to php

Open HuyetCongTu opened this issue 4 years ago • 2 comments

Your code don't convert Form data to php

demo:

--data-raw "id=438^&novel=Going-Back-and-Forth-Between-Earth-and-The-Other-World-with-Space-Time-Magic^&max=430^&page=2" ^

HuyetCongTu avatar Nov 19 '20 09:11 HuyetCongTu

Yep! I see a bug!

I have this:

curl 'https://example.com' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36' \
  --data-raw '{"min_name_length":10,"max_name_length":10}' \
  --compressed

Converted to this:

// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://example.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');

$headers = array();
$headers[] = 'Accept: application/json, text/plain, */*';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

And didn't show data-raw.

NabiKAZ avatar Mar 06 '21 01:03 NabiKAZ

Seem there are a pending pull request for this issue in here: https://github.com/incarnate/curl-to-php/pull/35

NabiKAZ avatar Mar 06 '21 01:03 NabiKAZ