选择语言 :

Module_HttpClient

HTTP请求数据核心类

常量
HttpClient::TYPE_CURL string(4) "Curl"
HttpClient::TYPE_FSOCK string(5) "Fsock"

API - Module_HttpClient

author
呼吸二氧化碳 jonwang@myqee.com
category
Module
package
HttpClient
copyright
Copyright © 2008-2013 myqee.com
license
http://www.myqee.com/license.html

$this->__construct( )

初始化


HttpClient::factory( )

获取实例化对象

返回值
  • HttpClient

HttpClient::is_support_curl( )

是否支持CURL

返回值
  • boolean

$this->set_agent( $agent = null)

设置$agent

参数列表

参数 类型 描述 默认值
$agent string $agent null
返回值
  • HttpClient

$this->set_cookies( $cookies )

设置$cookie

参数列表

参数 类型 描述 默认值
$cookies string $cookie
返回值
  • HttpClient

$this->set_referer( $referer )

设置$referer

参数列表

参数 类型 描述 默认值
$referer string $referer
返回值
  • HttpClient

$this->set_ip( $ip )

设置请求页面的IP地址

参数列表

参数 类型 描述 默认值
$ip string $ip
返回值
  • HttpClient

$this->set_header( $header )

设置请求页面的Header信息

$this->set_header('X-Auth-User: test');

参数列表

参数 类型 描述 默认值
$header string $header
返回值
  • HttpClient

$this->set_option( $key , $value )

设置参数

参数列表

参数 类型 描述 默认值
$key $key
$value $value
返回值
  • HttpClient

$this->set_multi_max_num( $num = 0)

设置多个列队默认排队数上限

参数列表

参数 类型 描述 默认值
$num int $num integer 0
返回值
  • HttpClient

$this->get( $url , $timeout = 10)

HTTP GET方式请求

支持多并发进程,这样可以大大缩短API请求时间

参数列表

参数 类型 描述 默认值
$url string/array 支持多个URL
$timeout array $data integer 10
返回值
  • string
  • HttpClient_Result 但个URL返回当然内容对象
  • Arr 多个URL时将返回一个数组对象

$this->post( $url , $data , $timeout = 30)

POST方式请求

参数列表

参数 类型 描述 默认值
$url $url
$data $data
$timeout $timeout integer 30
返回值
  • HttpClient_Result

$this->put( $url , $data , $timeout = 30)

PUT方式请求

参数列表

参数 类型 描述 默认值
$url $url
$data $data
$timeout $timeout integer 30
返回值
  • HttpClient_Result

$this->delete( $url , $timeout = 30)

DELETE方式请求

参数列表

参数 类型 描述 默认值
$url $url
$timeout $data integer 30
返回值
  • HttpClient_Result

$this->__call( )


$this->method( $method = null)

设置,获取REST的类型

参数列表

参数 类型 描述 默认值
$method string GET|POST|DELETE|PUT 等,不传则返回当前method null
返回值
  • string
  • HttpClient_Result

$this->driver( )

获取当前驱动

返回值
  • HttpClient_Driver_Curl