- 论坛徽章:
- 0
|
我执行该段PHP代码返回如下
HTTP/1.1 404 Object Not Found
Server: Microsoft-IIS/5.0
Date: Thu, 11 Nov 2004 08:38:53 GMT
Content-Type: text/html
Content-Length: 111
No web site is configured at this address.
但我直接在IE里执行http://221.11.133.33/short/groupsms.asp不是返回
404 Object Not Found
为什么?是否221.11.133.33的www server配置问题
不相信你们试一下这段代码!!!!!
程序代码如下
<?
//---- 数据准备
$URL="221.11.133.33"; //程序要访问的主机名.
$PORT=80; // 8000 是 http 协议端口.
$TIMEOUT=10; // 连接超时设定.
$content="发送测试"; //用户要发送的内容.
$phone="13999999999"; //指定目标手机号码.
$content= urlencode($content); //为了在http协议中传输,使用系统函数 urlencode对 要发送的文字内容做 urlencoding方式的编码.
$phone = urlencode($phone);
$user='test'; //发送所需的认证用户名.
$pass='123456'; //认证密码,认证错误将会出现返回值
$user = urlencode($user);
$pass = urlencode($pass);
$body="user=$user&pass=$pass&mobile=$phone&msg=$content"; //http 体信息.
$length= strlen($body); //体信息字节数.
//http 协议头信息
$head="GET /short/groupsms.asp HTTP/1.0 \n
Accept-Language: zh-cn \n
Content-Type: application/x-www-form-urlencoded \n
Host: 221.11.133.33 \n
Content-Length: $length \n
Pragma: no-cache";
$http="$head\n\n$body\n"; // http 完整的请求内容由 以上 头信息 + 2个回车符 +体信息+回车 组成
// ---- 发送
$fp = fsockopen($URL,$PORT,&$errno,&$errstr,$TIMEOUT); // 建立与 www.81nm.com的 http连接
if($fp)
{
fputs($fp, $http); // 发送信息.
while(!feof($fp))
{
$infostr=fgets($fp,12 ; //接收返回.
echo $infostr;
echo "<br>;";
}
fclose($fp);
}
else
{
$infostr='连接失败';
echo $infostr;
}
?>; |
|