APIs & Integrations

worldcup123
Member

How can i store access token and refresh token in php variable?

Hi, I wrote the code and received this json response:

{“refresh_token”:“xxx-xx-xx-xx-xx”,“access_token”:“xxxx”,“expires_in”:21600}

but access token is not getting stored on $myrs variable.

Here is the full code :


$cod=$_GET[“code”];

$url=“https://api.hubapi.com/oauth/v1/token?grant_type=authorization_code&client_id=x-x-x-x-x&client_secre...”.$cod;

$agent= ‘Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)’;

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_HTTPHEADER, [‘Content-Type: application/x-www-form-urlencoded’]);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL,$url);

$result=curl_exec($ch);

$rest= (json_decode($result, true));
$myrs=$rest[“access_token”];


How can i store the access token in a variable ?

Thank you!

0 Upvotes
1 Reply 1
worldcup123
Member

How can i store access token and refresh token in php variable?

Anyone to solve this issue ?

0 Upvotes