公众服务号如何实现一键登陆

dhrubber 2015-05-02 05:52:53
如下图



给个代码例子。
...全文
197 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dhrubber 2015-08-16
  • 打赏
  • 举报
回复
不好意思。楼上,结贴!
conqweal 2015-05-06
  • 打赏
  • 举报
回复
服务认证号,带网页授权功能,如果你运营的号不是服务认证号,可以其他的也利用别的服务认证号实现

public function joinUs(){
        if(!is_weixin()) return false;
        $wechat_info = $this->winfo;
        $w_id = getWid();
        if($wechat_info['w_auth']!=1){   
           //代理官方认证号
           if(SITEDOMAIN!='www.'.C('officialDomain')){
               $off_wid = D('User')->findProxyAuthen($w_id);
               if(!$off_wid) return false;              
               $wechat_info =  D('Wechat')->getWechatCache($off_wid);
           }else{
               //官方认证号
               $wechat_info = M('wechat_extend')->where(array('lower(w_weixin)'=>C('officialWx')))->find();
           }       
      
        }
        if($_GET['code']){           
           $cfg['appid'] = $wechat_info['w_appid'];
           $cfg['secret'] = $wechat_info['w_secret'];
           $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);
           $urs = json_decode(getRemoteContent('https://api.weixin.qq.com/sns/userinfo?access_token='.$s['access_token'].'&openid='.$s['openid'].'&lang=zh_CN'),true);
           if($urs['openid']){                  
             $r = M('wechat_user');  
             $uid = getUid();            
             $nickname = filterNickName($urs['nickname']);
             //当前公众号入库数据补充
             $sfile = './Public/Uploads/weixin/avatar/'.md5($urs['openid']).'.jpg';
             $data['headimgurl'] = D('WechatUser')->getAvatar($urs['headimgurl'],$sfile);
             $data = array('nickname'=>$nickname,'headimgurl'=>$sfile,'sex'=>$urs['sex'],'country'=>$urs['country'],'province'=>$urs['province'],'city'=>$urs['city']);
             M('wechat_user')->where(array('id'=>$uid))->save($data); 
             if($uid && $nickname && $nickname!='网友'){             
               $this->assign('msg','授权完成');
             }elseif(!$uid){
               $this->assign('msg','用户信息未入库,请检查公众号配置参数是否正确');
             }else{
               $this->assign('msg','很遗憾,请确认您的微信是否设置了昵称');
             }
             $this->display('index');
            
           }else{
             $this->assign('msg','授权失败');
             $this->display('index'); 
           }  
        }else{
            $this->assign('msg','您取消了授权');
            $this->display('index');           
           
        }

          
      }

dhrubber 2015-05-04
  • 打赏
  • 举报
回复
还没人给解答?
Jack_0817 2015-05-03
  • 打赏
  • 举报
回复
这个没研究过,弄过订阅号,但是手机不能登
dhrubber 2015-05-03
  • 打赏
  • 举报
回复
没人吗? 大神在哪里。。。。。。。。。。。

3,143

社区成员

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

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