圆月山庄资源网 Design By www.vgjia.com
ASP:
复制代码 代码如下:
<%
Option Explicit
Response.Buffer = true
Response.ContentType = "text/html"
Response.Charset = "gb2312″
Dim Url, Result
Url = "http://ping.baidu.com/ping/RPC2"
Result = BytesToBstr(SendPing(Url), "gb2312″)
IF Instr(Result, "<int>0</int>") > 0 Then
Response.Write("success")
Else
Response.Write("failure")
End IF
Function SendPing(Url)
Dim s : s = ""
Randomize()
Dim r : r = Int(Rnd() * 9999) + 1000
s = s & "<?xml version=""1.0″" encoding=""gb2312″"?>"
s = s & "<methodCall>"
s = s & "<methodName>weblogUpdates.ping</methodName>"
s = s & "<params>"
s = s & "<param><value><string>开发网站的一些小技巧</string></value></param>"
s = s & "<param><value><string>http://hi.baidu.com/subendong/blog</string></value></param>"
s = s & "<param><value><string>http://hi.baidu.com/subendong/blog/item/6cd9468d243e8c07b21bba5e.html</string></value></param>"
s = s & "<param><value><string></string></value></param>"
s = s & "</params>"
s = s & "</methodCall>"
Response.Write "<p>发送Ping到:" & Url & "</p>"
Response.Flush
Dim objPing
Set objPing = Server.CreateObject("MSXML2.ServerXMLHTTP")
objPing.SetTimeOuts 10000, 10000, 10000, 10000
‘第一个数值:解析DNS名字的超时时间10秒
‘第二个数值:建立Winsock连接的超时时间10秒
‘第三个数值:发送数据的超时时间10秒
‘第四个数值:接收response的超时时间10秒
objPing.open "POST", Url & "?r=" & r, False
objPing.setRequestHeader "Content-Type", "text/xml; charset=gb2312″
objPing.send(s)
SendPing = objPing.ResponseBody
Set objPing = Nothing
End Function
‘===============================================
‘函数名:BytesToBstr
‘作用:字符集转换
‘参数:body–内容;Cset–指定的字符集
‘===============================================
Function BytesToBstr(body, Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
PHP:
复制代码 代码如下:
<?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>https://www.jb51.net</string></value></param>
<param><value><string>https://www.jb51.net/a/15222.html</string></value></param>
<param><value><string>https://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失败";
}
?>
复制代码 代码如下:
<%
Option Explicit
Response.Buffer = true
Response.ContentType = "text/html"
Response.Charset = "gb2312″
Dim Url, Result
Url = "http://ping.baidu.com/ping/RPC2"
Result = BytesToBstr(SendPing(Url), "gb2312″)
IF Instr(Result, "<int>0</int>") > 0 Then
Response.Write("success")
Else
Response.Write("failure")
End IF
Function SendPing(Url)
Dim s : s = ""
Randomize()
Dim r : r = Int(Rnd() * 9999) + 1000
s = s & "<?xml version=""1.0″" encoding=""gb2312″"?>"
s = s & "<methodCall>"
s = s & "<methodName>weblogUpdates.ping</methodName>"
s = s & "<params>"
s = s & "<param><value><string>开发网站的一些小技巧</string></value></param>"
s = s & "<param><value><string>http://hi.baidu.com/subendong/blog</string></value></param>"
s = s & "<param><value><string>http://hi.baidu.com/subendong/blog/item/6cd9468d243e8c07b21bba5e.html</string></value></param>"
s = s & "<param><value><string></string></value></param>"
s = s & "</params>"
s = s & "</methodCall>"
Response.Write "<p>发送Ping到:" & Url & "</p>"
Response.Flush
Dim objPing
Set objPing = Server.CreateObject("MSXML2.ServerXMLHTTP")
objPing.SetTimeOuts 10000, 10000, 10000, 10000
‘第一个数值:解析DNS名字的超时时间10秒
‘第二个数值:建立Winsock连接的超时时间10秒
‘第三个数值:发送数据的超时时间10秒
‘第四个数值:接收response的超时时间10秒
objPing.open "POST", Url & "?r=" & r, False
objPing.setRequestHeader "Content-Type", "text/xml; charset=gb2312″
objPing.send(s)
SendPing = objPing.ResponseBody
Set objPing = Nothing
End Function
‘===============================================
‘函数名:BytesToBstr
‘作用:字符集转换
‘参数:body–内容;Cset–指定的字符集
‘===============================================
Function BytesToBstr(body, Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
PHP:
复制代码 代码如下:
<?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>https://www.jb51.net</string></value></param>
<param><value><string>https://www.jb51.net/a/15222.html</string></value></param>
<param><value><string>https://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失败";
}
?>
标签:
ping
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
更新日志
2024年11月18日
2024年11月18日
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】