Пример #1
0
 public function callback($type = null, $code = null)
 {
     if (empty($type) || empty($code)) {
         $this->error('参数错误');
     }
     $sns = ThinkOauth::getInstance($type);
     //腾讯微博需传递的额外参数
     $extend = null;
     if ($type == 'tencent') {
         $extend = array('openid' => $this->_get('openid'), 'openkey' => $this->_get('openkey'));
     }
     $tokenArray = $sns->getAccessToken($code, $extend);
     $openid = $tokenArray['openid'];
     //$token = $tokenArray['access_token'];  //根据需求储存  主要用来刷新并延长授权时间
     //dd($tokenArray);
     //
     //执行后续操作,代码自己实现。
     //请记住每个用户的openid都是唯一的,所以把openid存到数据库即可
     $member = D('MemberView');
     //根据openid判断用户是否存在,如果存在 ,判断用户是否被禁用。如果不存在,把openid存到数据库,相当于注册用户
     #
     #
     #  代码自己实现
     #
     #
     #
 }