Development, always failed to get token $ appid & nbsp; wx1aabc8673b8f103a; $ appsecret & nbsp; 9aa99fc9db9bf1321c1afe05feb29b6c; $ url & nbsp; api. weixin. qq. comcgi-bintoken? Grant _ development, always fail to get token
$appid = 'wx1aabc8673b8f103a';
$appsecret = '9aa99fc9db9bf1321c1afe05feb29b6c';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
$url='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx1aabc8673b8f103a&secret=9aa99fc9db9bf1321c1afe05feb29b6c';
//echo $access_token;
function getDo($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$jsoninfo = json_decode($output, true);
return $jsoninfo;
}
$arr=getDo($url);
$info_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$arr["access_token"]}&openid={$appid}&lang=zh_CN";
print_r(getDo($info_url));
Actually, you can get the token, that is, if you are using it, it will become invalid. what should you do?
------ Solution ----------------------
You can refer to the php script provided by the official php sdk to modify your program,
In addition, do you expose appid and appsecret .......
------ Solution ----------------------
First obtain the code, then use the code to obtain access_token and openid, and then obtain the user information.
------ Solution ----------------------
You only need to pass the token to userinfo. The returned result is openid and the like. you used getdo twice and the token is updated, and the query is the first token value.
------ Solution ----------------------
Openid = {$ appid}
An error is reported.
Step 1: the user agrees to the authorization and obtains the code
Step 2: exchange code for webpage authorization access_token
Reference: http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html