Social Auth For PHP Standalone Sites and Applications
Social Auth Plugin is the authentication and authorization solution based on social networks for web applications.
Nowaday, almost internet users have at least one account on social networks (like Facebook, Twitter or Google Plus …). Therefore allowing users log in your applications/sites (apps) via social network accounts is not only help your users approach your apps easily but also help you reduce amount of work which is not necessary to focus on developing your apps. So now I introduce you a simple way to make a Social Auth plugin for your apps.
SONHLAB Social Auth (SSA) Features:
- Registration and login base on social network sites.
- Get user data from social site (base on the social site’s support).
- Easy to deploy on several apps.
- Easy to store user data in your database (MySQL …).
- Social Network List: Facebook, Twitter, Google.
11 May 2018: Version 4.0:
- Update Facebook SDK 5.6.x
31 Mar 2017: Version 3.0:
- Update Facebook SDK 5.
02 Oct 2014: Version 2.0
- Update Facebook SDK 4.
- Update Goolge API.
- Update Twitter API.
- Change File Structure for more friendly.
26 Jul 2012:
- Add index.php file to test easier.
31 May 2012:
- First Version.
Installing SONHLAB Social Auth:
1. Download Free SONHLAB Social Auth (SSA) Plugin.
2. Unzip the downloaded file. After unzip you will have auth folder.
3. Upload auth folder to your server.
4. Modify appconf.php file in the auth folder:
Facebook: insert appid and secret info into the file (if you do not have yet you can get them from Facebook).
Twitter: Insert consumer_key and consumer_secret (if you do not have yet you can get them from Twitter). Then you also need to set Callback URL on Twitter App page (https://apps.twitter.com/). From your Twitter App page, choose your app and move to “Settings” tab, then set “Callback URL” point to “twitter.php” file in “/auth/platforms/twitter-app/” folder.
Example: In my demo, I set Callback URL:
Google: Insert Client ID and Client Secret (if you do not have yet you can get them from Google). Set “Redirect URIs” on Google page (the page you get Client ID and Client Secret). The “Redirect URIS” have to point to “google.php” file in “/auth/platforms/google-app/” folder.
In our demo, the home page is:
So the “Redirect URIS” I set for our demo is:
After you completed modifying appconf.php you can start to use the plugin.
When Authentication and Authorization are successful, user data will be store in $_SESSION[“userprofile”] (it’s an array). Then, you can use the data in any way you want (show it on the screen, store in your database, etc.).
This is just a basic tutorial to you can use this plugin quickly. For advance configurations please go to the social site and read their API Documentation.
Google OAuth 2.0 API Documentation.
That’s it. I hope you enjoyed this plugin and find it useful!
If you have questions or suggestions you can go to Social Auth PHP plugin Support Zone to discuss more.