daheilang

用微信打开地址(红色的为需要替换的内容)

 https://open.weixin.qq.com/connect/oauth2/authorize?appid=appid&redirect_uri=http://www.回调网址.com/xx.php&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect 
 
xx.php源码
<?php
$code = $_GET[\'code\'];//获取code 
$weixin = file_get_contents("https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx97842c91eebd5446&secret=4127fc2a585b86c14399e4fb22f8675f&code=".$code."&grant_type=authorization_code");//通过code换取网页授权access_token
$jsondecode = json_decode($weixin);//对JSON格式的字符串进行编码
$arr = get_object_vars($jsondecode);//转换成数组
$openid = $arr[\'openid\'];//输出openid
echo $openid;
?>

 

分类:

技术点:

相关文章:

  • 2022-02-02
  • 2022-01-26
  • 2022-12-23
  • 2021-04-16
  • 2021-12-07
  • 2021-07-15
  • 2021-05-04
猜你喜欢
  • 2022-12-23
  • 2022-02-08
  • 2021-09-27
  • 2022-01-29
  • 2022-12-23
  • 2021-09-16
  • 2022-02-01
相关资源
相似解决方案