zoukankan      html  css  js  c++  java
  • 微信开发 获取用户openId 与路由控制

    w实践,满足当前需求。

    www.w.com

    www.w.com/w1.php

    $wxurl='https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$wxwid.'&redirect_uri=http://www.w.com/woauth2.php&response_type=code&scope=snsapi_base&state=1#wechat_redirect';
    header('Location: '.$wxurl);

    www.w.com/woauth2.php

    $wxurl = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$wxwid
        .'&secret='.$wxws;
    
    $wxr_code = $_REQUEST['code'];
    
    $wxurl='https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$wxwid
        .'&secret='.$wxws.'&code='.$wxr_code.'&grant_type=authorization_code';
    $result = file_get_contents($wxurl);
    $res =json_decode($result, true);
    var_dump($res);
    $wxr_openid=$res['openid'];
    var_dump($wxr_openid);
  • 相关阅读:
    MRO C3算法 super的运用
    约束 抛异常
    反射
    Ubuntu
    Vim
    Vim
    Arithmetic
    Docker-常用命令
    Docker
    Docker-LAMP开发环境
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6441537.html
Copyright © 2011-2022 走看看