微信开发 获取用户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);

 

微信开发 获取用户openId 与路由控制

上一篇:微信小程序组件篇实战


下一篇:文章根据时间段显示的微信名和微信号3.0版(处理数据在服务器端)