kevinabraham kevinabraham - 2 years ago 488
PHP Question

How to use instagram api with guzzle 6+ and laravel?

Im trying to convert this url

Into something I can use with guzzle. So far I've got:

$token = "123456789";
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', '', [
'access_token' => $token
echo $res->getStatusCode();
// 200
echo $res->getHeaderLine('content-type');
// 'application/json; charset=utf8'
echo $res->getBody();
// {"type":"User"...'

but I just get an error that reads:

Client error: `GET` resulted in a `400 BAD REQUEST` response:
{"meta": {"error_type": "OAuthParameterException", "code": 400, "error_message": "Missing client_id or access_token URL (truncated...)

Answer Source

You should place your token in query like this:

$client = new \GuzzleHttp\Client;

$response = $client->get('', [
    'query' => [
        'access_token' => $token

return $response->getBody();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download