With the
https://api.weixin.qq.com/sns/oauth2/access_token? Appid=wxb6692daa2a19194 & amp; Appsecret=1808 e9ce5acb4c7f2838e8edcfd0a6a
Always an error
{" errcode ": 41004," errmsg ":" appsecret missing, hints: [req_id: 8 v6gia0320th20] "}
But the appsecret
CodePudding user response:
public function getBaseInfo ()
{
/Think/Log: : record (" PublicController: getBaseInfo called ", "DEBUG");
//1, the access code
$appid=C (" appid ");
$redirect_url=urlencode (C (' SERVER_ADDR '). '/index. PHP/Weixin/Public/getUserOpenId');
$url="https://open.weixin.qq.com/connect/oauth2/authorize? Appid=". $appid. "& amp; Redirect_uri=". $redirect_url. "& amp; The payload=code& The scope=snsapi_base & amp; The state=123 # wechat_redirect ";
The header (' location: '. $url);
The exit ();
}
//get the user openid
The public function getUserOpenId ()
{
/Think/Log: : record (" PublicController: getUserOpenId called ", "DEBUG");
$appid=C (" appid ");
$appsecret=C (' appsecret ');
$code=$_GET['code'];//get was obtained from the above function getBaseInfo
$url="https://api.weixin.qq.com/sns/oauth2/access_token? Appid=". $appid. "& amp; Secret=". $appsecret. "& amp; Code=". $code. "& amp; Grant_type=authorization_code ";
//3, obtain the openid
$res=json_decode (httpGet ($url));
$unionId=WxAccessTokenController: : getInstance () - & gt; GetGZHUnionid ($res - & gt; Openid);
$this - & gt; The assign (' unionId '$unionId);
$this - & gt; Display (" login ");
}
Above is my code, you should refer to the silent authorization, access code first, through the code to obtain the openid
CodePudding user response:
Appsecret error, is you have a problem the appsecretCodePudding user response:
Apparently appsecret problem, but this kind of situation, is often at the time of developing code, code to run about appsecret processing logic, a very weak weak carelessness, often after find the problem back to take a tumble, using layered method, is a common solution,1. Determine the surface layer, appsecret whether it is right or what brought a garbled or
2. Download WeChat official DEMO verification, network transmission, key information is correct, such as official DEMO if there is no problem that must be your development language is not compatible or code problems
3. The small program, little game to discuss Q69-3593-325
Wrong, can be ruled out judgment stratification is a common method
CodePudding user response:
This analysis look at smiled, this is not a parameter name write wrong? Should be secret not appsecret