php使用百度ping服務(wù)代碼實(shí)例
更新時間:2014年06月19日 10:30:55 投稿:junjie
這篇文章主要介紹了php使用百度ping服務(wù)代碼實(shí)例,百度ping服務(wù)可以加速對自己網(wǎng)站的收錄,一般在文章發(fā)表時調(diào)用,需要的朋友可以參考下
代碼實(shí)例:
<?php
function 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_POSTFIELDS, $postvar);
$res = curl_exec ($ch);
curl_close ($ch);
return $res;
}
$baiduXML = "<?xml version=\"1.0\" encoding=\"gb2312\"?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param><value><string>愚人渡</string></value></param>
<param><value><string>http://www.dhdzp.com</string></value></param>
<param><value><string>http://www.dhdzp.com/read.php?tid-96.html</string></value></param>
<param><value><string>http://www.dhdzp.com</string></value></param>
</params>
</methodCall>";
$res = postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML);
if ( strpos($res, "<int>0</int>") )
{
echo "PING成功";
}else{
echo "PING失敗";
}
?>
相關(guān)文章
談?wù)勀銓end SAPIs(Zend SAPI Internals)的理解
這篇文章主要介紹了談?wù)勀銓end SAPIs(Zend SAPI Internals)的理解的相關(guān)資料,需要的朋友可以參考下2015-11-11
PHP加密3DES報錯 Call to undefined function: mcrypt_module_open()
這篇文章主要介紹了PHP加密3DES報錯 Call to undefined function: mcrypt_module_open() 如何解決的相關(guān)資料,需要的朋友可以參考下2016-04-04
本文章來給各位同學(xué)介紹一下關(guān)于Php CURL模擬登陸論壇并采集數(shù)據(jù)實(shí)例,如果你對利用curl模擬登錄功能有興趣可進(jìn)入?yún)⒖肌?/div> 2015-05-05
thinkphp3.x中display方法及show方法的用法實(shí)例
這篇文章主要介紹了thinkphp3.x中display方法及show方法的用法,結(jié)合實(shí)例形式分析了thinkPHP3.x模板的功能、定義、賦值、渲染及輸出等技巧,需要的朋友可以參考下2016-05-05
如何在Laravel5.8中正確地應(yīng)用Repository設(shè)計模式
這篇文章主要介紹了如何在Laravel5.8中正確地應(yīng)用Repository設(shè)計模式,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11最新評論

