I am in the process of creating a website that ges informatin from an API that responds in JSON-format. I would like to execute the following command in PHP:
exec('curl -v -u {client_id}:{client_secret} -d code="{authorization_code}" -d redirect_uri={redirect_uri} -d grant_type=authorization_code https://api.basespace.illumina.com/v1pre3/oauthv2/token', $token);
This returns an array called $token which contains something of the following format:
Array
(
[0] => {"error":"invalid_grant","error_description":"Authorization code is unknown for this application or an access token has already been issued for it."}
)
In this example I would like to put the error and the error_description in seperate variables, for further processing.
I already thought of using substr(), but the content of $token can vary, so I think that won't work...
Is there another, more simple way to split the array?