Ashish Kumar Sahoo
Ashish Kumar Sahoo

Reputation: 95

How to get access token using PHP?

First of all I am authorizing my app at say, /oauth/authorize/. Then I am exchanging the authorization token for an access token at /oauth/access_token/. After successful exchange, I get an access token in json format on this page: /oauth/access_token/?code=CODE&client_secret=CLIENT_SECRET&client_id=CLIENT_ID&redirect_uri=REDIRECT_URL.

Format:

{"access_token": "ACCESS_TOKEN", "token_type": "simple"}

I want to save/get this access token locally. How do I do this in PHP?

Upvotes: 0

Views: 2294

Answers (1)

ariefbayu
ariefbayu

Reputation: 21979

You will need to convert the JSON result into PHP variable:

$result = json_decode($returnedJSON);
var_dump($result);

Your access_token is retrieved by using this code:

echo $result->access_token;

Upvotes: 2

Related Questions