2012-03-03 27 views
0

任何人都可以告訴我如何在Zend框架中實現Facebook應用程序登錄。我使用普通的PHP在Zend Framework中完成它,但它包含大量的問題和硬代碼。我的代碼包含Zend_Auth_Adapter進行身份驗證,其中我檢查了我的數據庫身份驗證以獲取正確的用戶名和密碼。我想爲Facebook登錄做同樣的事情。我提到很多教程,但那不起作用。如何實現這一點?給我一步一步的解決方案,因爲我是Zend Framework中的新手。或者提供任何提供一步一步解決方案的鏈接。在此先感謝在Zend Framework中使用zend_auth_adapter進行facebook登錄

+0

如何:https://github.com/erickthered/Facebook-PHP-SDK-for-Zend-Framework – 2012-03-03 12:18:42

回答

0

這其實很簡單。您需要使用Facebook sdk:https://github.com/facebook/php-sdk

基本代碼應改爲類似:

$fb = new Facebook($config); 
if($this->_getParam('code')) { 

    if($token = $fb->getAccessToken()) { 

    //Do your own logic, but log them in: 

    $result = new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user->id); 
    Zend_Auth::getInstance()->getStorage()->write($result->getIdentity()); 

    } else 
    //Clear identity 

} else 
    //redirect using $fb->getLoginUrl() 
相關問題