码迷,mamicode.com
首页 > Web开发 > 详细

http+socket发送短信

时间:2016-08-16 14:52:01      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:function   target   public   短信   

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发送短信

标签:function   target   public   短信   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!