Socialid.login.getUserInfo

(Difference between revisions)
Jump to: navigation, search
(API Response)
Line 5: Line 5:
 
== Usage ==
 
== Usage ==
  
   socialid.login.getUserInfo(handler)
+
   socialid.login.getUserInfo(handler, options)
  
 
== Parameters ==
 
== Parameters ==
Line 12: Line 12:
 
! align="left" width="200px" | handler
 
! align="left" width="200px" | handler
 
| width="200px" | optional
 
| width="200px" | optional
| Callback function to handle the API response.
+
| callback function to handle the API response.
 +
|+
 +
! align="left" width="200px" | options
 +
| width="200px" | optional
 +
| object containing additional parameters.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | fields
 +
| width="200px" | optional
 +
| a list of user profile field names to be returned, joined by commas. See [[Social Profile Fields]].
 
|}
 
|}
  
Line 19: Line 27:
 
{|
 
{|
 
! align="left" width="200px" | data
 
! align="left" width="200px" | data
| Javascript object containing data from the user logged in. The object properties are: user_id, name, email, location, picture_url, facebook, twitter, linkedin and gplus. The properties facebook, twitter, linkedin and gplus will be available only for the providers connected by the user.
+
| Javascript object containing data from the user logged in (see description below).
 
|+
 
|+
 
! align="left" width="200px" | status
 
! align="left" width="200px" | status
 
| The API response status. Can be '''success''', if there is an user logged in the current login session and its data was successfully retrieved, or '''not_found''', if there is no user logged in the current login session.
 
| The API response status. Can be '''success''', if there is an user logged in the current login session and its data was successfully retrieved, or '''not_found''', if there is no user logged in the current login session.
 +
|}
 +
 +
=== Response Data ===
 +
 +
The data object properties are:
 +
 +
{|
 +
! align="left" width="200px" | user_id
 +
| user id.
 +
|-
 +
! align="left" width="200px" | <span style="color: red">name</span>
 +
| <span style="color: red">user name. Warning: this field is deprecated. Use "display_name" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">email</span>
 +
| <span style="color: red">user e-mail. Warning: this field is deprecated. Use "verified_email" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">location</span>
 +
| <span style="color: red">user current location. Warning: this field is deprecated. Use "current_location" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">picture_url</span>
 +
| <span style="color: red">user picture url. Warning: this field is deprecated. Use "picture_url" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | profile
 +
| a hash with the fields request by the parameter "fields". This field will only be present if at least one field is requested.
 +
|-
 +
! align="left" width="200px" | <span style="color: red">facebook</span>
 +
| <span style="color: red">user Facebook profile data. This field will only be present if the user connected a Facebook credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">twitter</span>
 +
| <span style="color: red">user Twitter profile data. This field will only be present if the user connected a Twitter credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">linkedin</span>
 +
| <span style="color: red">user LinkedIn profile data. This field will only be present if the user connected a LinkedIn credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">gplus</span>
 +
| <span style="color: red">user Google+ profile data. This field will only be present if the user connected a Google+ credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.</span>
 
|}
 
|}
  

Revision as of 12:51, 7 December 2015

Contents

Description

API to get basic information about the user logged in the current login session.

Usage

 socialid.login.getUserInfo(handler, options)

Parameters

handler optional callback function to handle the API response.
options optional object containing additional parameters.
fields optional a list of user profile field names to be returned, joined by commas. See Social Profile Fields.

API Response

data Javascript object containing data from the user logged in (see description below).
status The API response status. Can be success, if there is an user logged in the current login session and its data was successfully retrieved, or not_found, if there is no user logged in the current login session.

Response Data

The data object properties are:

user_id user id.
name user name. Warning: this field is deprecated. Use "display_name" field in the "fields" parameter.
email user e-mail. Warning: this field is deprecated. Use "verified_email" field in the "fields" parameter.
location user current location. Warning: this field is deprecated. Use "current_location" field in the "fields" parameter.
picture_url user picture url. Warning: this field is deprecated. Use "picture_url" field in the "fields" parameter.
profile a hash with the fields request by the parameter "fields". This field will only be present if at least one field is requested.
facebook user Facebook profile data. This field will only be present if the user connected a Facebook credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.
twitter user Twitter profile data. This field will only be present if the user connected a Twitter credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.
linkedin user LinkedIn profile data. This field will only be present if the user connected a LinkedIn credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.
gplus user Google+ profile data. This field will only be present if the user connected a Google+ credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.

Example

Get basic information about the user logged in the current login session:

 socialid.login.init(1);
 var handler = function(response) {
    if (response.status == "success") {
       alert("Welcome " + response.data.name);
    } else {
       alert("Could not get info from the current logged in user.");
    }
 }
 socialid.login.getUserInfo(handler);

Example of "data" object:

 data = {
   user_id: 632,
   name: "John Doe",
   email: "johndoe@example.com",
   location: "New York",
   picture_url: "http://www.facebook.com/johndoe.jpg",
   facebook: {
      picture_url: "http://www.facebook.com/johndoe.jpg",
      profile_url: "http://www.facebook.com/johndoe"
   },
   twitter: {
      picture_url: "http://www.twitter.com/johndoe.jpg",
      profile_url: "http://www.twitter.com/johndoe"
   },
   linkedin: {
      picture_url: "http://www.linkedin.com/johndoe.jpg",
      profile_url: "http://www.linkedin.com/johndoe"
   },
   gplus: {
      picture_url: "http://plus.google.com/johndoe.jpg",
      profile_url: "http://plus.google.com/johndoe"
   }
 }

You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox