- json_decode: documentation ( source)
<?php
const NL = PHP_EOL;
$json = '{
"access_token": "ya29.Il-4B7Tpewa",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "1//09ghRt",
"scope": "https://www.googleapis.com/auth/fitness.location.read https://www.googleapis.com/auth/fitness.activity.read" } 1';
$jsonObj = json_decode($json);
echo $jsonObj->access_token;
echo NL;
echo $jsonObj->refresh_token;
echo NL;
echo $jsonObj->expires_in;
echo NL;
$jsonArr = json_decode($json, true);
echo $jsonArr['access_token'];
echo NL;
echo $jsonArr['refresh_token'];
echo NL;
echo $jsonArr['expires_in'];