Socialid.login.getUserInfo
From Social ID Developers
Revision as of 12:51, 7 December 2015 by Renato.neves (Talk | contribs)
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. |
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. |
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. | |
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. | |
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