Baidu ping interface Baidu ping method-PHP source code

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.