选择语言 :

 Module_HttpClient_Driver_Curl::get

GET方式获取数据,支持多个URL

string, Module_HttpClient_Driver_Curl::get( string/array $url [, $timeout $timeout = integer 10 ] )

参数列表

参数 类型 描述 默认值
$url string/array $url
$timeout $timeout integer 10
返回值
  • string, false on failure
File: ./modules/httpclient/driver/curl.class.php
public function get($url, $timeout = 10)
{
    if ( is_array($url) )
    {
        $getone = false;
        $urls = $url;
    }
    else
    {
        $getone = true;
        $urls = array($url);
    }

    if ($this->method=='GET')
    {
        // GET 方式不需要处理
    }
    else if ($this->method=='POST')
    {
        $this->set_option(CURLOPT_POST, true);
    }
    else if ($this->method=='PUT')
    {
        $this->set_option(CURLOPT_PUT, true);
    }
    else if ($this->method)
    {
        $this->set_option(CURLOPT_CUSTOMREQUEST, $this->method);
    }

    $data = $this->request_urls($urls, $timeout);

    $this->clear_set();

    if ( $getone )
    {
        $this->http_data = $this->http_data[$url];
        return $data[$url];
    }
    else
    {
        return $data;
    }
}