$url = "http://localhost/post.php";//要post的目标网址
$post_data = array (
 "foo" => "bar",
 "query" => "Nettuts",
 "action" => "Submit"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的变量加上,这个变量看网站需求而定
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
echo $output;//执行代码后应该会得到以下结果:

参考链接:http://www.knowsky.com/542626.html

标签: none

添加新评论