请教微信里的 oauth2.0


昨天做一个微信平台的web站,

简单来说有2个页面

index 和 me

在导航里, me的链接是做session判断的

if($_SESSION['uid']){
echo 'me.html';
}else{
echo 'oauth_url';
}

oauth的链接是这样的
https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd458831848213056&redirect_uri=http://115.29.98.171/wzx/auth-396.html&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect

现在问题是
1) 我的 scope 是 snsapi_userinfo 但是没有弹出 认证授权 页, 直接就获取 code了, 我直接在微信端打开这个链接可以 弹出 授权页 , 现在是 a 链接跳转的,打不开

2) 我想不通过A标签跳转, 如果使用php header('Location:oauth_url') 也能跳转, 不过获取的code 微信提示无效
{"errcode":40029,"errmsg":"invalid code"}

不知道这里面是什么问题

oauth2 php 微信公众平台

幻魔Dドール 9 years, 7 months ago

redirect_uri 需要 urlencode()

Oauth类
使用示例

阵亡Death answered 9 years, 7 months ago

Your Answer