Copy CodeThe code is as follows:
$get _data = Array (
"Get1" = "Get1",
"Get2" = "Get2",
"Get3" = "Get3"
);
$curl = Curl_init ();
curl_setopt ($curl, Curlopt_url, ' http://test.test.com/test.php? '). Http_build_query ($get _data));
curl_setopt ($curl, Curlopt_useragent, ' mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.11 (khtml, like Gecko) chrome/23.0.1271.97 safari/537.11 ');
curl_setopt ($curl, Curlopt_header, false);
curl_setopt ($curl, Curlopt_returntransfer, true);
curl_setopt ($curl, curlopt_followlocation, true);
$post _data = Array (
"P1" = "test1",
"P2" = "test2",
"P3" = "test3"
);
curl_setopt ($curl, Curlopt_post, true);
["Content_Type"]=> string ("Multipart/form-data"); boundary=------077a996f5afe "
To send a file, precede the file name with the @ prefix and use the full path.
When using an array to provide post data, the Curl component is presumably intended to be compatible with the @filename of this upload file, by default Content_Type is set to Multipart/form-data.
While there is no impact on most Web servers, there are still a few servers that are incompatible.
curl_setopt ($curl, Curlopt_postfields, $post _data);
["Content_Type"]=> string ("application/x-www-form-urlencoded")
curl_setopt ($curl, Curlopt_postfields, Http_build_query ($post _data));
In the absence of the need to upload files, as far as possible to the post submitted data http_build_query, and then sent out, to achieve better compatibility, smaller request packets.
$cookies = Array (
' C1 ' = ' v1 ',
' C2 ' = ' v2 ',
' C3 ' = ' v3 ',
);
$cookies _string = ";
foreach ($cookies as $name = = $value) {
$cookies _string. = $name. ' = '. $value. '; ';
}
curl_setopt ($curl, Curlopt_cookie, $cookies _string);
$result = curl_exec ($curl);
Curl_close ($curl);
Var_dump ($result);
Exit
http://www.bkjia.com/PHPjc/327924.html www.bkjia.com true http://www.bkjia.com/PHPjc/327924.html techarticle Copy the code as follows: PHP $get _data = Array ("Get1" = "Get1", "get2" = "Get2", "get3" = "Get3"); $curl = Curl_init (); Curl_seto PT ($curl, Curlopt_url, ' http://test.test.com/t ...