PHP obtains the user's openid (key Code) and codeopenid through the redirected Code parameter.
The key code is as follows:
// Get Login User information function getOpenID ($ appid, $ appsecret, $ code) {$ url = "https://api.weixin.qq.com/sns/oauth2/access_token? Appid = ". $ appid. "& secret = ". $ appsecret. "& code = ". $ code. "& grant_type = authorization_code"; $ weixin = file_get_contents ($ url); // use code in exchange for webpage authorization access_token $ jsondecode = json_decode ($ weixin ); // encode a string in JSON format $ array = get_object_vars ($ jsondecode); // convert it to an array $ openid = $ array ['openid']; // output openidreturn $ openid ;}
The above section describes how to use PHP to obtain the user's openid (key Code) through the jump Code parameter. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!