post - PHP cURL says Moved Permanently when POSTing to a virtual host -
i trying post data php curl local site that's using virtual hosts have custom domain http://example.local
, result seems moved permanently
. how work?
this current code:
$url = "http://example.local/paypal_ipn.php" $ch = curl_init(); //set url, number of post vars, post data curl_setopt($ch,curlopt_url, $url); curl_setopt($ch,curlopt_post, substr_count($req,'&')+1); curl_setopt($ch,curlopt_postfields, $req); //execute post $result = curl_exec($ch); //close connection curl_close($ch);
i've tried set curlopt_followlocation
true, follows without post data.
use curlopt_customrequest
instead of curlopt_post
like;
curl_setopt($curl, curlopt_customrequest, "post");
and 1 more thhing, need add
curl_setopt($curl, curlopt_postredir, 3);
3 means follow redirect same type of request both 301 , 302 redirects.
by doing this, second request post request well. note that, curlopt_postredir
implemented in php 5.3.2 here
Comments
Post a Comment