首页 > Web开发 > 详细

http+socket发送短信

时间:2016-08-16 14:48:47      阅读:257      评论:0      收藏:0      [点我收藏+]
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;
}


本文出自 “我的PHP之路” 博客,请务必保留此出处http://phpme.blog.51cto.com/663593/1839200

http+socket发送短信

原文:http://phpme.blog.51cto.com/663593/1839200

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!