微信

作者: yuanlu954 | 来源:发表于2019-03-28 10:11 被阅读0次

获取openid

https://open.weixin.qq.com/connect/oauth2/authorize?appid=你的微信appid&redirect_uri=你的授权的回调地址&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect

    $utfgbk = mysql_query("set names utf8");
    $code = $_GET['code'];//获取code
    $weixin = file_get_contents("https://api.weixin.qq.com/sns/oauth2/access_token?appid=你的微信appid&secret=微信密匙&code="
    .$code."&grant_type=authorization_code");//通过code换取网页授权access_token,(利用code间接获取用户数据组)
   $jsondecode = json_decode($weixin); //对JSON格式的字符串进行编码
   $array = get_object_vars($jsondecode);//转换成数组(用户数据组)
   $openid = $array['openid'];//输出openid
   mysql_query("insert into openid(openids)values('$openid')");//添加到数据库;
''

相关文章

网友评论

      本文标题:微信

      本文链接:https://www.haomeiwen.com/subject/havfbqtx.html