public function setProxy($host, $port, $type = CURLPROXY_HTTP)
  {
    static $types_str = [
      'HTTP', 'SOCKS4', 'SOCKS5', 'SOCKS4A', 'SOCKS5_HOSTNAME'
    ];
    $types = [];
    foreach ($types_str as $type_str) {
      if (defined('CURLPROXY_' . $type_str)) {
        $types[] = constant('CURLPROXY_' . $type_str);
      }
    }
    if (! in_array($type, $types)) {
      throw new \Exception('Invalid proxy type specified.');
    }

    $this->_proxy['host'] = $host;
    $this->_proxy['port'] = (int) $port;
    $this->_proxy['type'] = $type;
  }
public function setProxy($host, $port, $type = CURLPROXY_HTTP)
  {
    static $types_str = [
      'HTTP', 'SOCKS4', 'SOCKS5', 'SOCKS4A', 'SOCKS5_HOSTNAME'
    ];
    $types = [];
    foreach ($types_str as $type_str) {
      if (defined('CURLPROXY_' . $type_str)) {
        $types[] = constant('CURLPROXY_' . $type_str);
      }
    }
    if (! in_array($type, $types)) {
      throw new \Exception('Invalid proxy type specified.');
    }

    $this->_proxy['host'] = $host;
    $this->_proxy['port'] = (int) $port;
    $this->_proxy['type'] = $type;
  }
public function setProxy ( $ host , $ port , $ type = CURLPROXY_HTTP ) { static $ types_str = [ 'HTTP' , 'SOCKS4' , 'SOCKS5' , 'SOCKS4A' , 'SOCKS5_HOSTNAME' ] ; $ types = [ ] ; foreach ( $ types_str as $ type_str ) { if ( defined ( 'CURLPROXY_' . $ type_str ) ) { $ types [ ] = constant ( 'CURLPROXY_' . $ type_str ) ; } } if ( ! in_array ( $ type , $ types ) ) { throw new \ Exception ( 'Invalid proxy type specified.' ) ; } $ this -> _proxy [ 'host' ] = $ host ; $ this -> _proxy [ 'port' ] = ( int ) $ port ; $ this -> _proxy [ 'type' ] = $ type ; }
Sets the proxy

@param string       $host Proxy host
@param int          $port Proxy port
@param int optional $type Proxy type, defaults to HTTP

@return void
@throws \Exception
Sets the proxy