duannei1477 2013-01-02 12:28
浏览 40

除了我的用户ID之外,无法使用Facebook登录

I am trying to create login with facebook with my application.The problem is I'm able to access the application with my facebook userid but not with the others.It say am error occured. Below is my code,Could anyone please check upon it and let me know what I am doing wrong?

public function fbverifyAction(){

        $facebook = new Facebook(array(
                  'appId'  => 'xxxxxx',
                  'secret' => 'xxxxxxxxx',
                   'cookie' => false,
           ));
         $user = $facebook->getUser();   
         if ($user) {
                 $uid = $facebook->getUser();
         $me = $facebook->api('/me');
                 $db = Zend_Registry::get('dbadapter');
          $select = new Zend_Db_Select($db);    
          $select = $db->select();
          $select = $db->select();
          $select->from(array('owner' => 'owner'),array             ('idowner','username','firstname','password','fb_config'));
          $select->where('owner.fb_config = ?',$me['id']);
          $stmt = $select->query();
          $result = $stmt->fetchAll();
        if(count($result) > 0)
        {
           $usr = $result[0]['username'];
            $pass = $result[0]['password'];
            $url1 = $this->address."access/verify?   username=$usr&password=$pass";
         }
        else
        {    
            $uid = $facebook->getUser();
                     $permissions = $facebook->api(
                                    '/me/permissions ',
                                            'GET',
                                    array(
                                 'access_token' => $facebook->getAccessToken()
                                ));
                             $perdetails['firstname'] =$permissions['first_name'];
                            $perdetails['lastname']=$permissions['last_name'];
                            $perdetails['username']=$permissions['username'];
                            $perdetails['fb_config']=$permissions['id'];
                            $db->insert('owner', $perdetails);

        }

            echo "<script type='text/javascript'>top.location.href = '$url1';</script>"; 
                            }
        else {
           echo '<script>top.location.href="'.$facebook->getLoginUrl().'";</script>';

       }
    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计