復制代碼 代碼如下:
function postUrl($url, $postvar)
{
$ch = curl_init();
$headers = array(
"POST ".$url." HTTP/1.0","Content-type: text/xml; charset=/"gb2312/"",
"Accept: text/xml",
"Content-length: ".strlen($postvar)
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
$res = curl_exec ($ch);
curl_close
($ch);
return $res;
}
$baiduXML = "encoding=/"gb2312/"?>
$res
= postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML);
if ( strpos($res, "
{
echo
"PING成功";
}
else
{
echo "PING失敗";
}
?>
以上就介紹了huoyingrenzhezhongwenwang PHP的博客ping服務代碼,包括了huoyingrenzhezhongwenwang方面的內容,希望對PHP教程有興趣的朋友有所幫助。
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答