复制代码 代码如下:
<?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>web开发笔记</string></value></param>
<param><value><string>http://www.jb51.net</string></value></param>
<param><value><string>http://www.jb51.net/001</string></value></param>
<param><value><string>http://www.jb51.net</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失败";
}
?>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!