1

我正在尝试使用我的应用程序使用 facebook 创建登录名。问题是我可以使用我的 facebook 用户 ID 访问该应用程序,但不能使用其他人。它说发生了错误。下面是我的代码,任何人都可以检查它并让我知道我做错了什么吗?

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>';

       }
    }
4

0 回答 0