In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to use Baidu automatic ping". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Use method access when automatically ping to Baidu, my method is to generate cache, update cache when automatically ping Baidu, return a result of 0 indicates success.
The copy code is as follows:
$pingarcurl=' http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$arcping = new Ping ('', $pingarcurl,get_domain (), 'https://www.jb51.net');
$arcping- > pingbaidu ()
The copy code is as follows:
Class ping {
Private$title;// blog name
Home address of private$hosturl;// blog
Private$arturl;// new post address
Private$rssurl;// blog rss address
Private$baiduXML;// Baidu XML structure
Private$baiduRPC;// Baidu XML address
Publicfunction__construct ($title,$arturl,$hosturl,$rssurl)
{
If (empty ($title) | | empty ($arturl))
Returnfalse
$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.=''
}
Publicfunctionpingbaidu ()
{
$ch=curl_init ()
$headers=array (
'User-Agent:request'
'Host:ping.baidu.com'
'Content-Type:text/xml'
);
Curl_setopt ($ch,CURLOPT_URL,$this- > baiduRPC)
Curl_setopt ($ch,CURLOPT_HEADER,1)
Curl_setopt ($ch,CURLOPT_RETURNTRANSFER,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
}
}
Functionget_domain ()
{
/ * Agreement * /
$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 million dollars) 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=newPing ('website title', 'updated URL address', 'website domain name', 'rss address')
/ / $arc=newPing ('title',get_arcurl of your website ($id), get_domain (),' http://www.abc.com/rss.php');
/ / echo$arc- > pingbaidu ()
/ / A result of 0 indicates success.
This is the end of the content of "how to use Baidu automatic ping". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.