In the previous parts of this series, we created our initial interfaces, set up our Google+ login functionality and talked about how we can merge our accounts together. In this article, we will integrate Twitter and Facebook within our application. You will see a lot of similarities with the Google+ article, so if you could follow that one easily, you won’t have much trouble with this one. If you haven’t read that article yet, I suggest you read it first before continuing this article.
You can view the code for all the articles on this Github page.
Twitter login
Once again, we start off by creating the following directory: src/SitePoint/SocialLogin/Twitter
. Within this directory, we create the TwitterLogin
class. This class implements the SocialLoginInterface
interface which we created in the first article. Make sure a property called service
is available to store our service in.
Like Google+, Twitter has some specific needs to make sure we can log in. So make sure we have the following 3 properties present in the class:
- Client id
- key
- callback URL
Since all 3 properties are required for our application to work, our constructor will receive these 3 variables as parameters and set the properties.
Up until now, your code should look the same as the first example in the Google+ article.
Our next step is to create our Twitter service. We will be using the same OAuth library and will set up a connection within the init method.
Before we can start, we have to add some use statements to the top of our class.
Continue reading %Social Network Authentication: Twitter and Facebook%
more
{ 0 comments... » Social Network Authentication: Twitter and Facebook read them below or add one }
Post a Comment