function httpPost($sURL,$aPostVars)
{
$srv_ip = '域名';//你的目標服務地址或頻道.
$srv_port = 80;
$url = $sURL; //接收你post的URL具體地址
$fp = '';
$resp_str = '';
$errno = 0;
$errstr = '';
$timeout = 300;
$post_str = $aPostVars;//要提交的內容.
$fp = fsockopen($srv_ip,$srv_port,$errno,$errstr,$timeout);
if (!$fp)
{
echo('fp fail');
}
$content_length = strlen($post_str);
$post_header = "POST $url HTTP/1.1\r\n";
$post_header .= "Content-Type:application/x-www-form-urlencoded\r\n";
$post_header .= "User-Agent: MSIE\r\n";
$post_header .= "Host: ".$srv_ip."\r\n";;
$post_header .= "Content-Length: ".$content_length."\r\n";
$post_header .= "Connection: close\r\n\r\n";
$post_header .= $post_str."\r\n\r\n";
//echo $post_header;
//echo $aPostVars;
fwrite($fp,$post_header);
$inheader = 1;
while (!feof($fp)) {
$line = fgets($fp,1024); //去除請求包的頭只顯示頁面的返回數據
if ($inheader && ($line == "\n" || $line == "\r\n")) {
$inheader = 0;
}
if ($inheader == 0) {
echo $line;
}
}
}
$content = "您的注冊驗證碼為8268,該驗證碼10分鐘內有效。如非本人操作請忽略此短信!【浪馳軟件】";
$content = iconv("utf-8","gb2312//IGNORE",$content); //如果是UTF-8 需要轉碼GB2312
httpPost("/LANZGateway/DirectSendSMSs.asp","UserID=999999&Account=lanz2016
&Password=735FF0028B7831D2783DD7EE98E3095DB94A1D64&Content=$content&Phones=11111111111&ReturnXJ=1");
|
XML: <?xml version="1.0" encoding="GB2312"?> <LANZ_ROOT> <ErrorNum>0</ErrorNum> <JobID>2321313130</JobID> <PhonesSend>98</PhonesSend> <ErrPhones>13855556666;13611112222</ErrPhones> <DeductionSMSs>1000</DeductionSMSs> </LANZ_ROOT> JSON: { "LANZ_ROOT": { "ErrorNum": "0", "JobID": "2321313130", "PhonesSend": "98", "ErrPhones": "13855556666;13611112222", "DeductionSMSs": "1000" } }
|