求助,微信内置浏览器打开的网页,获取微信用户openid

gzpepco 2015-01-09 01:27:12
我已开通300元的开发者账号。
需求如下:
现有一wap网页,用户使用微信内置浏览器打开(通过微信朋友圈/朋友分享,微信扫网页二维码等方式进入,与公众号无关),该网页如何获取用户的微信openid呢?

按照官方的微信登录帮助,是可以实现扫码登录,但是针对PC版的--微信扫码,电脑端登录。而我的情况是当前网页是在手机微信打开的,还怎么扫码呢?

我见有些网站是可以实现的,会弹出授权提示框,但不知是如何实现的?谢谢了!!
...全文
4035 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
酷龙王子 2015-10-21
  • 打赏
  • 举报
回复
楼主 解决了吗额 我现在也遇到这样的问题 怎么解决的啊
conqweal 2015-01-25
  • 打赏
  • 举报
回复
$r_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if(!$this->_get('code')){ getOfficialOpenId(1,'base',$r_url); }else{ getOfficialOpenId(2); }
conqweal 2015-01-25
  • 打赏
  • 举报
回复
function getOpenid($step,$type='base',$backurl=null,$minwen=1,$app_id,$app_secret){ if(!is_weixin()) return false; $cfg = array('appid'=>$app_id,'secret'=>$app_secret); switch ($step) { case '2': $s = json_decode(getRemoteContent('https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$cfg['appid'].'&secret='.$cfg['secret'].'&code='.$_GET['code'].'&grant_type=authorization_code'),true); cookie(md5('share_openid'),$s['openid']); $u = json_decode(getRemoteContent('https://api.weixin.qq.com/sns/userinfo?access_token='.$s['access_token'].'&openid='.$s['openid'].'&lang=zh_CN'),true); if($u['errcode']){ $s['w_id'] = $w_id; //处理手机的用户信息,没有昵称头像..... }else{ $u['w_id'] = $w_id; //处理手机的用户信息,带昵称头像..... } break; default: $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$cfg['appid']."&redirect_uri=".urlencode($backurl)."&response_type=code&scope=snsapi_".$type."&state=1#wechat_redirect"; if($minwen){ $html = "<!doctype html><html><head></head><body>"; $html .= "<div style='font-size:2em;margin-top:40%;text-align:center;'>页面加载中,请稍候...</div><script>location.href='".$url."'</script>"; $html .= "</body></html>"; die($html); }else{ @header("location:".$url); } } }
chenglyb 2015-01-22
  • 打赏
  • 举报
回复
http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html
whatisma 2015-01-10
  • 打赏
  • 举报
回复
开发文档-用户管理-网页授权获取用户基本信息 这里面写的很详细了

3,156

社区成员

发帖
与我相关
我的任务
社区描述
微信开发即微信公众平台开发,将企业信息、服务、活动等内容通过微信网页的方式进行表现,通过二次开发可以将公众账号由一个媒体型营销工具转化成提供服务的产品。
社区管理员
  • 微信开发
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧