Created
January 25, 2016 12:40
-
-
Save yagihiro/e7e91d4e5e5acf302c40 to your computer and use it in GitHub Desktop.
instagram_oauth_token_request_sample.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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