Skip to content

Instantly share code, notes, and snippets.

@yagihiro
Created January 25, 2016 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yagihiro/e7e91d4e5e5acf302c40 to your computer and use it in GitHub Desktop.
Save yagihiro/e7e91d4e5e5acf302c40 to your computer and use it in GitHub Desktop.
instagram_oauth_token_request_sample.php
use GuzzleHttp\Client as Guzzle;
// ...
if ($request->has('code')) {
$params = $request->all();
$g = new Guzzle;
$postParams = [
'form_params' => [
'client_id' => config('services.instagram.client_id'),
'client_secret' => config('services.instagram.client_secret'),
'grant_type' => 'authorization_code',
'redirect_uri' => config('services.instagram.redirect'),
'code' => $params['code'],
]
];
$response = $g->post('https://api.instagram.com/oauth/access_token', $postParams);
$body = json_decode($response->getBody());
$token = $body->access_token;
// 以降 $token をつかって API コールする
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment