我有一个http GET
方法网址
http://test.com/test.php?name=sam&age=20
现在我在一个不同的网站,我想打电话,或者说ping这个网址,以便推送'get'内容而不会实际开始重定向到该网址。
php中是否有一个函数或方法来完成它?
答案 0 :(得分:2)
例如,
$urlStringData = "http://test.com/test.php?name=sam&age=20";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10); # timeout after 10 seconds, you can increase it
curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt($ch, CURLOPT_URL, $urlStringData ); #set the url and get string together
$return = curl_exec($ch);
curl_close($ch);