For help, php automatically ping Baidu and then .... my younger brother has a php Site. I didn't use rss to automatically ping Baidu, but I want to add one. so I found the following code on the Internet: PHPcode & lt ;? PhpfunctionpostUrl ($ url, $ postvar) {$ chcurl_init (); $ headersarray ("POS for help, php automatically ping Baidu and then ....
My younger brother has a php Site. I didn't use rss to automatically ping Baidu, but I want to add one. so I found the following code on the Internet:
PHP code
weblogUpdates.extendedPing
$url
$url
”;$res = postUrl(‘http://ping.baidu.com/ping/RPC2′, $baiduXML);?>
Then there will be no more...
I would like to ask you, how can we achieve this RSS automatic ping to Baidu? Please take the following steps. The younger brother is a php Cainiao!
------ Solution --------------------
PHP code
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;} $ url = ''; // You do not know what this value is. $ baiduXML ="
WeblogUpdates. extendedPing
$ Url
$ Url
"; Echo $ res = postUrl ('http: // ping.baidu.com/ping/RPC2', $ baiduXML );