热门IT资讯网

http+socket发送短信

发表于:2024-11-25 作者:热门IT资讯网编辑
编辑最后更新 2024年11月25日,public function Post($data, $target) { $url_info = parse_url($target); $httpheader = "POST "
public  function Post($data, $target) {
$url_info = parse_url($target);
$httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
$httpheader .= "Host:" . $url_info['host'] . "\r\n";
$httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n";
$httpheader .= "Content-Length:" . strlen($data) . "\r\n";
$httpheader .= "Connection:close\r\n\r\n";
//$httpheader .= "Connection:Keep-Alive\r\n\r\n";
$httpheader .= $data;

$fd = fsockopen($url_info['host'], 80);
fwrite($fd, $httpheader);
$gets = "";
while(!feof($fd)) {
$gets .= fread($fd, 128);
}
fclose($fd);
if($gets != ''){
$start = strpos($gets, ');
if($start > 0) {
$gets = substr($gets, $start);
}
}
return $gets;
}


0