public static function buildHttpClient(
        $url = NULL,
        $username = NULL,
        $password = NULL,
        $contentType = self::CONTENT_JSON_API,
        $language = self::HEADER_LOCALE
    )
    {
        $client = new Client($url);
        $client->setHead([
            'Accept: ' . $contentType,
            'Accept-Language: ' . $language,
            'Content-Type: application/vnd.api+json'
        ]);

        if (is_scalar($username) && is_scalar($password)) {
            $client->setOptions([CURLOPT_HTTPAUTH, CURLAUTH_ANY]);
            $client->setOption(CURLOPT_USERPWD, $username . ':' . $password);
        }

        return $client;
    }
public static function buildHttpClient(
        $url = NULL,
        $username = NULL,
        $password = NULL,
        $contentType = self::CONTENT_JSON_API,
        $language = self::HEADER_LOCALE
    )
    {
        $client = new Client($url);
        $client->setHead([
            'Accept: ' . $contentType,
            'Accept-Language: ' . $language,
            'Content-Type: application/vnd.api+json'
        ]);

        if (is_scalar($username) && is_scalar($password)) {
            $client->setOptions([CURLOPT_HTTPAUTH, CURLAUTH_ANY]);
            $client->setOption(CURLOPT_USERPWD, $username . ':' . $password);
        }

        return $client;
    }
public static function buildHttpClient ( $ url = NULL , $ username = NULL , $ password = NULL , $ contentType = self :: CONTENT_JSON_API , $ language = self :: HEADER_LOCALE ) { $ client = new Client ( $ url ) ; $ client -> setHead ( [ 'Accept: ' . $ contentType , 'Accept-Language: ' . $ language , 'Content-Type: application/vnd.api+json' ] ) ; if ( is_scalar ( $ username ) && is_scalar ( $ password ) ) { $ client -> setOptions ( [ CURLOPT_HTTPAUTH , CURLAUTH_ANY ] ) ; $ client -> setOption ( CURLOPT_USERPWD , $ username . ':' . $ password ) ; } return $ client ; }
Obtiene un cliente de HTTP.
@param string $url
@param string $username
@param string $password
@return Client
Obtiene un cliente de HTTP .