$json = file_get_contents(‘url_here’);
$obj = json_depre($json);
echo $obj->access_token;
为此,
file_get_contents需要
allow_url_fopen启用它。可以通过在运行时完成以下操作来实现:
ini_set("allow_url_fopen", 1);您也可以使用
curl获取网址。要使用卷曲,可以使用中发现的例子在这里:
$ch = curl_init();// importANT: the below line is a security risk, read https://paragonie.com/blog/2017/10/certainty-automated-cacert-pem-management-for-php-software// in most cases, you should set it to truecurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_URL, 'url_here');$result = curl_exec($ch);curl_close($ch);$obj = json_depre($result);echo $obj->access_token;



