Home > Backend Development > PHP Tutorial > PHP obtains the user's openid key code through the Code parameter of WeChat jump

PHP obtains the user's openid key code through the Code parameter of WeChat jump

WBOY
Release: 2016-07-28 08:27:18
Original
1136 people have browsed it

The key code is as follows:

//获取微信登录用户信息
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);//通过code换取网页授权access_token
$js //对JSON格式的字符串进行编码
$array = get_object_vars($jsondecode);//转换成数组
$openid = $array['openid'];//输出openid
return $openid;
}
Copy after login

The above is the editor’s introduction to PHP to obtain the user’s openid (key code) through the Code parameter of WeChat jump. I hope it will be helpful to everyone. If you have any questions If you have any questions, please leave me a message and I will reply to you in time. Thank you very much for your support of this website!

The above introduces how PHP obtains the user's openid key code through the Code parameter of WeChat jump, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template