, Php automatically ping Baidu and then.

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

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.