https_request是调用第三方接口的方法。
Print $output is a value, can see the Access_token, but the printing $jsoninfo is empty, so the back of the return Access_token also get not
$output =$this->https_request($url); $jsoninfo = json_decode($output, true); $access_token = $jsoninfo["access_token"]; return $access_token;
The problem is resolved
Cause: In the method of acquiring a third-party interface, there are already json_decode
Reply content:
https_request是调用第三方接口的方法。
Print $output is a value, can see the Access_token, but the printing $jsoninfo is empty, so the back of the return Access_token also get not
$output =$this->https_request($url); $jsoninfo = json_decode($output, true); $access_token = $jsoninfo["access_token"]; return $access_token;
The problem is resolved
Cause: In the method of acquiring a third-party interface, there are already json_decode
That means json_decode
it failed.
json_decode
after json_last_error()
that, use the function to see what the error is.
1. json字符串必须以双引号包含$output = str_replace("'", '"', $output);2. json字符串必须是utf8编码$output = iconv('gbk', 'utf8', $output);3.不能有多余的逗号 如:[1,2,]用正则替换掉,preg_replace('/,\s*([\]}])/m', '$1', $output)
Problems have been found, personal reasons