Zend framework user authentication integration with Twitter and Facebook

为君一笑 提交于 2019-11-30 04:22:24

问题


Is there any script based on ZF, which supports normal user signup/login system, along with user authentication throuh Twitter and Facebook.


回答1:


Have a look at An example of OpenID, Facebook and Twitter authentication in Zend Framework 1.11. Altough, the application does not show how to use normal user authentication (it was not the purpose of it) it shows one way of using OpenID (Google, Yahoo, MyOpenId, AOL, OpenId) as well as Facebook Connect and Twitter Oauth for authentication of users. This is more difficult to do in ZF than regular user authentication.




回答2:


Don't know about twitter but you can use the Facebook PHP SDK easily enough in a ZF project. There's an excellent example in the SDK "examples" folder.

My approach is to

  • Add the Facebook object as an application resource plugin, eg

require_once 'facebook.php';

class My_Application_Resource_Facebook extends Zend_Application_Resource_ResourceAbstract
{
    public function init()
    {
        $facebook = new Facebook($this->getOptions());

        Zend_Registry::set('facebook', $facebook);

        return $facebook;
    }
}

  • Check the Facebook session and user in your Bootstrap.php file, adding it to Zend_Auth if applicable
  • Include the Facebook JavaScript SDK in your layout
  • Use the Login Button to authenticate your users

Because the Facebook auth token is cookie based, both your server-side code and client-side JS can access it.

Edit Twitter libraries here - http://dev.twitter.com/pages/libraries#php



来源:https://stackoverflow.com/questions/5175846/zend-framework-user-authentication-integration-with-twitter-and-facebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!