D
D
Danil Sysoev2016-02-03 23:19:57
PHP
Danil Sysoev, 2016-02-03 23:19:57

What is the correct way to use curl?

Hello guys. Faced such a question.
In general, I connect the API. I pass authorization through oauth2.
Stopped at the stage of obtaining a token. When I send a request with a code, it transfers to a page with the following code (as I understand it - json):

{
"access_token":"123c123dd94ccc1232303fb79f80a025390a50bdccaedca8d2349e9c65a2ce19",
"token_type":"bearer",
"expires_in":7200,
"refresh_token":"321c321dd94ccc3213213fb79f80a025390a50bdccaedca8d2349e9c65a2ce19",
"scope":"wallet:user:read wallet:accounts:read"
}

How to get the acceess_token value written to a variable?
Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Seredny, 2016-02-03
@smidl

To begin with, write this curl'a response to a variable, for example $answer;
Then decode it from Json into an object (you can also into an array, about this is in the documentation)
And then you just refer to the access_token field of the newly created object
$token = $object->access_token

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question