Implementation On Websites \ Getting Started

In the first part of the guide you will discover how to setup your database in order to store the user_token and how to add a simple callback script to your system.

If the setup of your website is different, you should still be able to follow this guide, some sections may however not be relevant for you.

Start by setting up your database

You first of all have to add a new table to your database. For MySQL you can use a table like in our example below. You may have to tweak it slightly if you represent your internal user identifiers differently.

		CREATE TABLE `user_token_link` (
		 `user_id` INT(10) UNSIGNED NOT NULL ,
		 `user_token` CHAR(36) NOT NULL ,
		  `user_id` ,

The user_id is the id that uniquely identifies user entries in your users table - feel free to rename the column at your convenience. The user_token uniquely identifies social network users, you will obtain it from our API after a user has logged in with his social network account.

When you receive a user_token from our API, you can match it against this table to check whether the social network account is already linked to a user account in your proprietary system or not. If you find a match for the user_token, then you can use the user_id to lookup the user record in your users table.

You should add the following functions to your system. Please note that these are only examples, you have to implement them depending upon your own system and database.

user_token user_id
		 * Return the user identifier for a user_token received by OneAll. 
		 * The goal is to check if there is an existing user account for a user_token received by OneAll.
		function get_user_id_for_user_token (user_token){
			// Example Query: SELECT user_id FROM user_token_link WHERE user_token = <user_token>
			// Return the user_id or null if none found.
user_id user_token
		 * Return the user_token for a given user identifier.
		 * The goal is to check if the given user identifier has already been linked to a OneAll user_token.
		function get_user_token_for_user_id (user_id){
			// Example Query: SELECT user_token FROM user_token_link WHERE user_id = <user_id>
			// Return the user_token or null if none found.
user_token user_id
		 * Link a user_token to an existing user identifier.
		 * The goal is to store a user_token for a given user_id so that we can recognize the user_token lateron.
		function link_user_token_to_user_id (user_token, user_id){
			// Example: INSERT INTO user_token_link SET user_token = <user_token>, user_id = <user_id>
			// Return true

Continue by setting up your system

Create the callback script

Create a new file on your server. If you use PHP you might call it callback_handler.php and use the code below to get started. After a user has signed in/up using one of our services, he will be redirected back to this script. The script then makes a call to the OneAll API in order to retrieve the user's social network profile data.


		// Check if we have received a connection_token
		if ( ! empty ($_POST['connection_token']))
		  echo "Connection token received: ".$_POST['connection_token'];
		  echo "No connection token received";

Integrate Social Login

You should now be able to open the callback script in your browser and you should see the message No connection token received when opening the file. Please keep the URL to this file handy as it will be used during the next steps of the guide. In the setup guide the link to this file is called your_callback_uri.

Your database should now be ready for the integration and you should have setup the first version of the callback script. Continue now with the Social Login implementation.

User Contributed Notes