8p / EightPointsGuzzleBundle

⛽️ Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony
MIT License
440 stars 71 forks source link

Attempted to call an undefined method named "send" of class "GuzzleHttp\Psr7\Response" #16

Closed acmartinsalmeida closed 9 years ago

acmartinsalmeida commented 9 years ago

I've updated to symfony 2.7 and PHP to 5.5 Get this error.

What i'm missing ?

florianpreusner commented 9 years ago

Hi,

please provide more information:

Thanks.

acmartinsalmeida commented 9 years ago

HI and thanks

"eightpoints/guzzle-bundle": "dev-master"

config.yml

guzzle:
    clients:
        api_wiki:
            base_url: "http://fr.wikipedia.org"

            headers:
                Accept: "application/json"
 $client   = $this->get('guzzle.client.api_wiki');
 $request = $client->get("/w/api.php?action=query&prop=extracts&exintro=&format=json&continue=&titles=**whatever**");
 $response = $request->send();

This bundle worked fine before guzzle 6 and 5.5 requirement

Thanks

florianpreusner commented 9 years ago

Hi,

thanks for adding data. You don't have to use send() anymore. When using get() a response will be returned directly:

$client = $this->get('guzzle.client.api_wiki');
$response = $client->get('https://api.github.com/user', ['auth' =>  ['user', 'pass']]);
echo $response->getStatusCode();
// "200"
echo $response->getHeader('content-type');
// 'application/json; charset=utf8'
echo $response->getBody();

You can find more information in Guzzle documentation: http://docs.guzzlephp.org/en/latest/

Best regards Florian