How to integrate the login using Google+ plus API in PHP

In the previous post we have already see how to integrate the LinkedIn Login with API and now make for Google+ API in PHP. Compare with LinkedIn Google is the best & everyone have a account in google all of they maintain simply in one account in google. That’s why peoples are like google.

Now we see how to make the Google OAuth in PHP. Actually the code is same for compare with LinkedIn OAtuth so you have easily understand this article.

Google Developer Console

First, you need Client ID & Client Secret code to make the OAuth connection so here I have teach you how to get that just follow the steps here.

In the left sidebar Library tab will be visible, you have just click that and search Google+ API. Then click to Enable the Google+ API.

Hereafter click Credentials.

Click Create Credential tab button, Select Oauth Client ID

Then list of Application type will be visible, you have just choose web application & create button.

Then enter the Authorized Javascript Origins URL. The URL like http://www.w3tweaks.com

Then fill the Authorized redirect URIs it like http://www.w3tweaks.com/googlelogin

Finally click Save Button.

It’s like,

Database Configuration

Now move on the PHP code to integrate the Googel OAuth API. So first create one database the database name is googlelogin then just import the users.sql file in your database. Now the database side will be finished.

Integrate PHP code in Google+

So now open the gpConfig.php file and edit the following things like Client ID, Client Secret & redirect url. The code is

When you have change the Client ID & secret it will affect your code, so don’t change & delete. Suppose if you have delete just create another project and make the client ID’s to fetch the same credentials.

Homepage for Google+ OAuth

This is your own design, you have write any code to UI design to make the attractive look for your user. So just make the new things like attractive login page example. The sample code is,