看看这个你能弄出来吗?
http://www.phpe.net/articles/134.shtml 它这个分类我搞了...
作者 008 发布于 0000-00-00 分类:php基础编程
目的:用263的短信接口发短信 没有成功!!!!苦闷!!!!
代码:
<?
function send_headers ($fp) {
fputs ($fp, "Accept: */*
");
fputs ($fp, "Accept-Language: en
");
fputs ($fp, "Connection: Keep-Alive
");
fputs ($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
");
}
// 发送数据和接受回复
function post_data ($host, $url, $data) {
$fp = @fsockopen ($host, 80, $errno, $errstr, 120);
$ret = "";
if (strncasecmp ($url, "http://", 7) == 0) $url = substr ($url, 7);
$req = strchr($url,"/");
if (! $req) {
$req = "/";
}
if ($fp) {
fputs ($fp, "POST $req HTTP/1.0
");
send_headers ($fp);
fputs ($fp, "Content-type: application/x-www-form-urlencoded
");
$out = "";
while (list ($k, $v) = each ($data)) {
if(strlen($out) != 0) $out .= "&";
$out .= rawurlencode($k). "=" .rawurlencode($v);
}
$out = trim ($out);
fputs ($fp, "Content-length: ".strlen($out)."
");
fputs ($fp, "$out");
fputs ($fp, "
");
while(!feof($fp)){
$ret .= fgets($fp,128);
}
fclose ($fp);
}
return $ret;
}
$reply = post_data ("http://sms.263.net", "/cgi-bin/y2k/bin/dxyc_send.cgi", array
("message" => "test", "dest_tel" => "13693081****","mytel" => "13693081***","mypwd"
=> "201201"));
echo $reply;
?>
逛论坛交流:使用fsockopen发送post信息的函数的问题??特难!
>你有电信的协议?
>你试着在HTTP头上加上 REFERER: 字段,指示引用页面,可能263坚持你的引用页面。
>顶
3 条回复
回复