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, '<?xml');
if($start > 0) {
$gets = substr($gets, $start);
}
}
return $gets;
}
http+socket发送短信
原创
©著作权归作者所有:来自51CTO博客作者hgditren的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python中两种网络编程方式:Socket和HTTP协议
本文将介绍Python中两种主要的网络编程方式:Socket编程和基于HTTP协议的网络编程,并通过实际案例来演示它们的应用。
Python 网络编程 Socket HTTP协议 -
socket发送http请求JAVA
















