最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

利用PHP fsockopen 模擬POST/GET傳送數(shù)據(jù)的方法

 更新時間:2015年09月22日 14:38:34   投稿:mrr  
使用php可以模擬post和get傳送數(shù)據(jù)到別的網(wǎng)頁或者是站點,那么怎么傳送數(shù)據(jù)呢?下面由小編給大家介紹利用PHP fsockopen 模擬POST/GET傳送數(shù)據(jù)的方法,需要的朋友一起看看吧

使用php可以模擬 post 和 get 傳送數(shù)據(jù)到別的網(wǎng)頁或站點

$arr=array(
  'user'=>'test',
  'password'=>''
);
sock_get($post_url,$arr);
sock_post($post_url,$arr); 
//fsocket模擬get提交
function sock_get($url,$query=array()){
  $query_str = http_build_query($query);
  $<span id="_nwp" style="width: auto; height: auto; float: none;"><a id="_nwl"  target="_blank" mpid="" style="text-decoration: none;"><span style="color:#ff;font-size:px;width:auto;height:auto;float:none;">info</span></a></span> = parse_url($url);
  $port = isset($info['port'])? $info['port'] : ;
  $query_str = empty($info["query"])?$query_str:$info["query"].'&'.$query_str;
  $fp = fsockopen($info["host"], $port, $errno, $errstr, );
  if(!$fp){
    return FALSE;
  }
  //$<span id="_nwp" style="width: auto; height: auto; float: none;"><a id="_nwl"  target="_blank" mpid="" style="text-decoration: none;"><span style="color:#ff;font-size:px;width:auto;height:auto;float:none;">head</span></a></span> = "GET ".$info['path']."?".$info["query"]." HTTP/.\r\n";
  $head = "GET ".$info['path']."?".$query_str." HTTP/.\r\n";
  $head .= "Host: ".$info['host']."\r\n";
  $head .= "\r\n";
  $write = fputs($fp,$head);
  while(!feof($fp)){
    $<span id="_nwp" style="width: auto; height: auto; float: none;"><a id="_nwl"  target="_blank" mpid="" style="text-decoration: none;"><span style="color:#ff;font-size:px;width:auto;height:auto;float:none;">line</span></a></span> = fread($fp,);
    echo $line;
  }
  fclose($fp);
  return true;
}
//fsockopen模擬POST
function sock_post($url,$<span id="_nwp" style="width: auto; height: auto; float: none;"><a id="_nwl"  target="_blank" mpid="" style="text-decoration: none;"><span style="color:#ff;font-size:px;width:auto;height:auto;float:none;">data</span></a></span>=array()){
  $query = http_build_query($data); 
  $info = parse_url($url);
  $fp = fsockopen($info["host"], , $errno, $errstr, );
  $head = "POST ".$info['path']."?".$info["query"]." HTTP/.\r\n";
  $head .= "Host: ".$info['host']."\r\n";
  $head .= "Referer: http://".$info['host'].$info['path']."\r\n";
  $head .= "Content-type: application/x-www-form-urlencoded\r\n";
  $head .= "Content-Length: ".strlen(trim($query))."\r\n";
  $head .= "\r\n";
  $head .= trim($query);
  $write = fputs($fp, $head);
  while (!feof($fp))
  {
    $line = fread($fp,);
    echo $line;
  }
}

以上內(nèi)容是給大家分享的利用PHP fsockopen 模擬POST/GET傳送數(shù)據(jù)的方法,希望大家能夠喜歡,更多有關(guān)php fsockopen知識請持續(xù)關(guān)注本站,謝謝。

相關(guān)文章

最新評論

扎囊县| 富裕县| 麻江县| 远安县| 根河市| 广东省| 专栏| 肇庆市| 翼城县| 上高县| 兖州市| 南京市| 剑阁县| 涪陵区| 南溪县| 平度市| 台山市| 邓州市| 青阳县| 肥西县| 温州市| 保定市| 双鸭山市| 上高县| 新巴尔虎右旗| 印江| 固安县| 黎城县| 德钦县| 烟台市| 苏尼特右旗| 将乐县| 墨竹工卡县| 广宁县| 宣武区| 页游| 海口市| 武清区| 武城县| 扶余县| 自治县|