public $buf " /> 国产精品美女久久久久人,天天操操,午夜视频在线观看网站

中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

php實現(xiàn)httpclient類示例

復(fù)制代碼 代碼如下:
httpClient::init($httpClient, $args = null);
$httpClient->get($url, $data = null, $cookie = null);
var_dump($httpClient->buffer);

復(fù)制代碼 代碼如下:
<?php

class httpClient {

 public $buffer = null;  // buffer 獲取返回的字符串
 public $referer = null;  // referer 設(shè)置 HTTP_REFERER 的網(wǎng)址
 public $response = null; // response 服務(wù)器響應(yīng)的 header 信息
 public $request = null;  // request 發(fā)送到服務(wù)器的 header 信息
 private $args = null;

 public static function init(&$instanceof, $args = array()) {
  return $instanceof = new self($args);
 }

 private function __construct($args = array()) {

  if(!is_array($args)) $args = array();
  $this->args = $args;
  if(!empty($this->args['debugging'])) {
   ob_end_clean();
   set_time_limit(0);
   header('Content-Type: text/plain; charset=utf-8');
  }

 }

 public function get($url, $data = null, $cookie = null) {

  $parse = parse_url($url);
  $url .= isset($parse['query']) ? '&'. $data : ( $data ? '?'. $data : '' );
  $host = $parse['host'];

  $header  = 'Host: '. $host. "/r/n";
  $header .= 'Connection: close'. "/r/n";
  $header .= 'Accept: */*'. "/r/n";
  $header .= 'User-Agent: '. ( isset($this->args['userAgent']) ? $this->args['userAgent'] : $_SERVER['HTTP_USER_AGENT'] ). "/r/n";
  $header .= 'DNT: 1'. "/r/n";
  if($cookie) $header .= 'Cookie: '. $cookie. "/r/n";
  if($this->referer) $header .= 'Referer: '. $this->referer. "/r/n";

  $options = array();
  $options['http']['method'] = 'GET';
  $options['http']['header'] = $header;

  $response = get_headers($url);
  $this->request = $header;
  $this->response = implode("/r/n", $response);
  $context = stream_context_create($options);
  return $this->buffer = file_get_contents($url, false, $context);

 }

 public function post($url, $data = null, $cookie = null) {

  $parse = parse_url($url);
  $host = $parse['host'];

  $header  = 'Host: '. $host. "/r/n";
  $header .= 'Connection: close'. "/r/n";
  $header .= 'Accept: */*'. "/r/n";
  $header .= 'User-Agent: '. ( isset($this->args['userAgent']) ? $this->args['userAgent'] : $_SERVER['HTTP_USER_AGENT'] ). "/r/n";
  $header .= 'Content-Type: application/x-www-form-urlencoded'. "/r/n";
  $header .= 'DNT: 1'. "/r/n";
  if($cookie) $header .= 'Cookie: '. $cookie. "/r/n";
  if($this->referer) $header .= 'Referer: '. $this->referer. "/r/n";
  if($data) $header .= 'Content-Length: '. strlen($data). "/r/n";

  $options = array();
  $options['http']['method'] = 'POST';
  $options['http']['header'] = $header;
  if($data) $options['http']['content'] = $data;

  $response = get_headers($url);
  $this->request = $header;
  $this->response = implode("/r/n", $response);
  $context = stream_context_create($options);
  return $this->buffer = file_get_contents($url, false, $context);

 }

}

httpClient::init($httpClient, array( 'debugging' => true , 'userAgent' => 'MSIE 15.0' ));
$httpClient->get('http://www.baidu.com', 'name=haowei');
echo $httpClient->request; // 獲取 請求頭部信息
echo $httpClient->response; // 獲取 響應(yīng)的頭部信息
echo $httpClient->buffer; // 獲取 網(wǎng)頁內(nèi)容

$httpClient->get('http://www.jb51.NET/ServiceLogin/', 'hash='. $time, 'uid=1;users=admin;')

echo $httpClient->buffer;

php技術(shù)php實現(xiàn)httpclient類示例,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲免费视频一区 | 成在线人视频免费视频 | 三级特黄特色视频 | 青青久久 | 色视频免费 | 精品伊人 | 成人亚洲精品 | 欧美性久久久 | 国产亚洲第一页 | 日韩精品久久 | 亚洲一区二区久久久 | 亚洲精品91 | 99精品国产一区二区三区 | 欧美一区二区三区久久精品 | 91精品国产综合久久精品 | 欧美成人在线免费 | 精品在线一区 | 夜夜草天天草 | 亚洲国产成人一区二区 | 欧美一区二区三区精品免费 | 精品日本久久久久久久久久 | 久久精品影视 | 91久久久久| 成人激情视频免费在线观看 | 成人免费在线播放视频 | 黑人精品欧美一区二区蜜桃 | 久久久久一区 | 精品欧美激情精品一区 | 一区二区手机在线 | 日韩欧美在线一区二区 | 国产精彩视频一区 | 日韩在线免费 | 福利视频网站 | 欧美在线不卡 | 久久久久国产一区二区三区 | 一区二区中文字幕 | 伊人一区| 精品免费av| 亚洲精品久久视频 | 一级片免费在线观看 | 午夜精品影院 |