加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php使用百度ping服务代码实例

发布时间:2020-12-12 20:14:46 所属栏目: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,$ur

代码实例:

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,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"?>

weblogUpdates.extendedPing 愚人渡 //www.52php.cn //www.52php.cn/read.php?tid-96.html //www.52php.cn ";

$res = postUrl('http://ping.baidu.com/ping/RPC2',$baiduXML);

if ( strpos($res,"0") )
{
echo "PING成功";
}else{
echo "PING失败";
}

?>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读