php - How to log in social networking sites like facebook, twitter and google+ to my websites in Zend Framework 1.12?

219

How to integrate the Social websites Facebook, twitter and Google+ in our website .

When a user comes to use an application in our website he must first log in through any of the above website, how this can be done using zend framework 1.12?

Is there any plugin combine available for the three websites? Or how can this be done? Thanks in advance

382

Answer

Solution:

needed to write a login procedure so that people could login with either Facebook, Twitter or Google. It is also possible to login with a combinations of these providers at the same time, so you could make use of multiple API’s. This way you could for example post a tweet (Twitter) and a wallpost (Facebook) for your user at the same time.

You can find code here:

Update: demo online at http://thebestsolution.org/projects/ZendMultipleAuthentications/. Your data is not saved, it is just a proof of concept!

Facebook

For Facebook login OAuth 2.0 is used. This is a really nice and simplistic protocol for authentication, but Zend has not (yet) implemented it in the framework. So I wrote a consumer class to handle the Oauth2 requests. To use the API of Facebook I made my own Facebook Resource class.

Twitter

Twitter uses the OAuth 1.0 protocol Zend already has classes to handle the OAuth 1.0 behavior. To access the API the Twitter Resource class is used.

Google

Google has multiple options for authentication. I first tried the OAuth 2.0, but this isn’t useful for login because it doesn’t remember the permissions the user has agreed on for accessing resources. So every time the user authenticate the question is asked to give permission to the users Google resources. I gave up and used the OpenId protocol which could not only provide a login service but also could access some of the user info. Zend has classes for the OpenId protocol and they are used to connect with Google. The OpenId consumer in the Zend Framework doesn’t support Google. Follow instructions from this comment.

*Update: Google has changed their authorization protocol for OAuth2 (link). Now Google remembers authorization given for OAuth2 resources so I changed the code to use OAuth2 instead of OpenID for Google login. We can use the Google API with the Google Resource class.

People are also looking for solutions to the problem: php - If url is /store/*

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.