Php uses Baidu ping Service Code instance _ php instance

Source: Internet
Author: User
This article mainly introduces the use of Baidu ping Service Code instances in php. Baidu ping service can accelerate the indexing of its own website, which is generally called when the article is published. If you need it, refer to the following code example:

<? Phpfunction postUrl ($ url, $ postvar) {$ ch = curl_init (); $ headers = array ("POST ". $ url. "HTTP/1.0", "Content-type: text/xml; charset = \" gb2312 \ "", "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_POSTFIELD S, $ postvar); $ res = curl_exec ($ ch); curl_close ($ ch); return $ res ;}$ baiduXML = "<? Xml version = \ "1.0 \" encoding = \ "gb2312 \"?>
   
  
   
WeblogUpdates. extendedPing
    
      
   
   
    
     
Yurendu
    
       
   
   
    
     
Http://www.php.net
    
       
   
   
    
     
Http://www.php.net/read.php? Tid-96.html
    
       
   
   
    
     
Http://www.php.net
    
     
  
 "; $ Res = postUrl ('HTTP: // ping.baidu.com/ping/RPC2', $ baiduXML); if (strpos ($ res ,"
 
  
0
 ") {Echo" PING succeeded ";}else {echo" PING failed ";}?>

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.