I am converting some Perl code to PHP.
However, I do not know much about Perl, so I have to code it with a rough meaning.
And, I do not understand what the below Perl code means...
What is the meaning of $req2->content(<<"POST_DATA")
and --$boundary
?
I've searched the Perl documentation, but it's too hard to find.
PHP code:
...
$boundary= 'Nobody-has-the-intention-to-erect-a-wall';
$req2 = curl_init($search_url);
curl_setopt($req2, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($req2, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($req2, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($req2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($req2, CURLOPT_COOKIE, $cookie);
curl_setopt($req2, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data;boundary='.$boundary,
'Content-Length: ' . strlen($data_string))
);
$result= curl_exec($req2);
...
Perl code:
...
my $boundary= 'Nobody-has-the-intention-to-erect-a-wall';
$req2->content_type('multipart/form-data;boundary='.$boundary);
$req2->header("Cookie"=>"access_token_cookie=$access_token_cookie; csrf_access_token=$csrf_access_token");
$req2->content(<<"POST_DATA"); #what means this?
--$boundary
Content-Disposition: form-data; name="num_result"
Content-Type: text/plain
$num_result
--$boundary
Content-Disposition: form-data; name="img"; filename="search.jpg"
Content-Type: image/jpeg
$image
--$boundary--
POST_DATA
my $res = $ua->request($req2);
...