Baidu Ping service PHP implementation and Google Ping service
Baidu Ping Service PHP implementation:
$baiduXML = <<
<>
Weblogupdates.extendedping
Small Orange Lamp Classified information network
http://www.xiaojudeng.com
www.xiaojudeng.com
Http://www.xiaojudeng.com/sitemaps.xml
EOT;
$res = PostURL (' http
:// PING.BAIDU.COM/PING/RPC2 ', $baiduXML);//The following is the decision to return success (according to the interface description of Baidu ping) if (Strpos ($res, "
0
")) echo" Ping succeeded "; else echo "Ping failed";
Google Ping Service Code:
$googleXML = <<
<>
Weblogupdates.extendedping
Small Orange Lamp Classified information network
http://www.xiaojudeng.com
/
http
www.xiaojudeng.com
http://www.xiaojudeng.com/sitemaps.xml
END; $res = PostURL (' http://blogsearch.google.com/ping/RPC2 ', $googleXML);//
The following is the decision to return success (according to the interface description of Google ping) if (Strpos ($res, "
0
")) echo "Ping succeeded"; else echo "Ping failed";
The PostURL function code is as follows:
function PostURL ($url, $postvar) { $ch = Curl_init (); $headers = Array ( "POST". $url. " http/1.0 ", " content-type:text/xml;charset=\ "utf-8\" "," 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;}
Reprinted from Http://www.js8.in/644.html