Baidu ping interface Baidu ping method jumps
Class ping {private $ title; // blog name private $ hosturl; // blog homepage address private $ arturl; // New article address private $ rssurl; // Blog rss address private $ baiduXML; // Baidu XML structure private $ baiduRPC; // Baidu XML address public function _ construct ($ title, $ arturl, $ hosturl, $ rssurl) {if (empty ($ title) | empty ($ arturl) return false; $ this-> title = $ title; $ this-> hosturl = $ hosturl; $ this-> rssurl = $ rssurl; $ this-> arturl = $ arturl; $ this-> baiduRPC =' http://ping.baidu.com/ping/RPC2 '; $ This-> baiduXML = ''; $ this-> baiduXML. = ''; $ this-> baiduXML. = 'weblogupdates. extendedPing '; $ this-> baiduXML. = ''; $ this-> baiduXML. = ''. $ this-> hosturl. ''; $ this-> baiduXML. = ''. $ this-> title. ''; $ this-> baiduXML. = ''. $ this-> arturl. ''; $ this-> baiduXML. = ''. $ this-> rssurl. ''; $ this-> baiduXML. = ''; $ this-> baiduXML. = '';} public function pingbaidu () {$ ch = curl_init (); $ headers = array ('User-Agent: request', 'host: p Ing.baidu.com ', 'Content-Type: text/XML',); curl_setopt ($ ch, CURLOPT_URL, $ this-> baiduRPC); curl_setopt ($ ch, CURLOPT_HEADER, 1 ); curl_setopt ($ ch, batch, 1); curl_setopt ($ ch, CURLOPT_POST, 1); curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headers); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ this-> baiduXML); $ res = curl_exec ($ ch); curl_close ($ ch); // return $ res; return (strpos ($ res, "0 "))? True: false ;}} function get_domain () {/* protocol */$ protocol = 'http ://'; /* domain name or IP address */if (isset ($ _ SERVER ['http _ X_FORWARDED_HOST ']) {$ host = $ _ SERVER ['http _ X_FORWARDED_HOST'];} elseif (isset ($ _ SERVER ['http _ host']) {$ HOST = $ _ SERVER ['http _ host'];} else {/* PORT */if (isset ($ _ SERVER ['server _ port']) {$ port = ':'. $ _ SERVER ['server _ port']; if (': 80' = $ PORT & 'http: //' = $ protocol) | (': 443 '= $ port & 'https: //' = $ protocol) {$ port = '';}} else {$ port = '';} if (isset ($ _ SERVER ['server _ name']) {$ host = $ _ SERVER ['server _ name']. $ port;} elseif (isset ($ _ SERVER ['server _ ADDR ']) {$ host = $ _ SERVER ['server _ ADDR']. $ port;} return $ protocol. $ host;} // $ arc = new Ping ('website title', 'updated URL address', 'website domain name', 'RSS address '); // $ arc = new Ping ('your website title', get_arcurl ($ id), get_domain (),' http://www.abc.com/rss.php '); // Echo $ arc-> pingbaidu (); // if the returned result is 0, the request is successful.