PHP ~ use curl do POST

$toURL = "http://SomeDomain/SamplePath?SomeVar=XX";
$post = array(
"a"=>"123",
"b"=>"321",
);
$ch = curl_init();
$options = array(
CURLOPT_URL=>$toURL,
CURLOPT_HEADER=>0,
CURLOPT_VERBOSE=>0,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_USERAGENT=>"Mozilla/4.0 (compatible;)",
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>http_build_query($post),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
echo $result;


source
http://blog.roodo.com/esabear/archives/16358749.html

沒有留言:

發佈留言