$url = 'YOUR API URL GOES HERE';
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));
$result = curl_exec($cURL);
curl_close($cURL);
$json = json_decode($result, true);
print_r($json);
ВЫХОД
Array
(
[access_token] => ya29.Il-4B1111
[token_type] => Bearer
//....
)
Теперь вы можете работать с переменной $json
в виде массива:
echo $json['access_token'];
echo $json['token_type'];