用asp与php实现百度ping服务的代码(2)


);
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 = "<?xml version=\"1.0\" encoding=\"gb2312\"?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param><value><string>黑区网络</string></value></param>
<param><value><string>//www.jb51.net</string></value></param>
<param><value><string>//www.jb51.net/a/15222.html</string></value></param>
<param><value><string>//www.jb51.net</string></value></param>
</params>
</methodCall>";
$res = postUrl(‘http://ping.baidu.com/ping/RPC2′, $baiduXML);
if ( strpos($res, "<int>0</int>") )
{
echo "PING成功";
}
else
{
echo "PING失败";
}
?>