Connects the user to a specified social network. A connection is an established session with the social network, which expires according to the social network's policy. A valid and active connection gives your site access to the user's social graph as well as the ability to perform various social actions, such as publishing a newsfeed item to the social network.
Note: This method is also supported in our REST API. If you wish to execute this method from your server, please refer toREST API > socialize.addConnection.
The following providers currently support this operation:
The following table lists the available parameters:
|||provider||string||The provider to which to connect. The optional values for this parameter are: facebook, twitter, googleplus, linkedin, microsoft, instagram, renren, yahoo, vkontakte, mixi, yahoojapan, odnoklassniki, wechat (Note: messenger has been replaced by microsoft, however, for backward compatibility, either can be used)..|
SAML providers are also supported - the format of the provider name is saml-<name>.
|||actionAttributes||JSON object||In Gamification, your users receive points for actions they perform on your site. In this case, adding a connection grants the user points. Action Attributes may be used to annotate actions with additional information, such as the section of the web site that generated the action. If you set here the actionAttributes, each time a user adds a connection, the action also receives an attribute, for example "tv-show":"glee", which can mean that the action was performed on the "Glee" page of the site. |
actionAttributes contain a JSON object comprised of a series of attribute keys (categories) with associated values. You can also use a generic "tags" key.
No more than three values can be given, they can be with a single key or each have their own key.
For more information see Variants and Action Attributes. Action attributes are later used to filter GM Plugins by a certain attribute.
|||authFlow||string||This parameter enables you to specify that the adding connection flow will use page redirects instead of a popup. This supports environments where popups are unavailable (e.g. mobile web view controls). This parameter accepts two values:|
A reference to a callback function. Gigya calls the specified function along with the results of the API method when the API method completes.
The callback function should be defined with the following signature: functionName(Response).
The "Response Object Data Members" table below provides specification of the data that is passed to the callback function.
A string of maximum 100 characters length. The CID sets categories for transactions that can be used later for filtering reports generated by Gigya in the "Context ID" combo box. The CID allows you to associate the report information with your own internal data. For example, to identify a specific widget or page on your site/application. You should not define more than 100 different context IDs.
A developer-created object that is passed back unchanged to the application as one of the fields in the response object.
This parameter accepts a comma-separated list of additional data fields to retrieve. The current valid values are: languages, address, phones, education, honors, publications, patents, certifications, professionalHeadline, bio, industry, specialties, work, skills, religion, politicalView, interestedIn, relationshipStatus, hometown, favorites, likes, followersCount, followingCount, username, locale, verified, irank, timezone, and samlData.
Note: Before your application can retrieve Facebook data, the user must grant your application with access. Please make sure you have checked the check boxes that enable retrieving the relevant fields from Facebook in the Permissions page on Gigya's website. You may find more information in the Facebook Permissions section of our guide.
|||facebookExtraPermissions||string||A comma-delimited list of Facebook-extended permissions to request from the user. This parameter gives the possibility to request extended permissions in addition to the permissions that Gigya already requests. Refer to Facebook's extended permissions page for the complete list of permissions.|
For example, if you wish to RSVP to events on the user's behalf and to to send text messages to the user, define: facebookExtraPermissions : "rsvp_event,sms"
|||forceAuthentication||Boolean||The default value of this parameter is 'false'. If it is set to 'true', the user is forced to provide their social network credentials during login - even if the user is already connected to the social network. This parameter is currently supported by Facebook, Twitter, Renren, and LinkedIn. Note that the behavior of the various social networks may be slightly different: Facebook expects the current user to enter their password, and will not accept a different user name. Other networks prompt the user to re-authorize the application or allow a different user to log in.|
|||googleExtraPermissions||string||This parameter gives the possibility to request extended permissions in addition to the permissions that Gigya is already requesting. The supported values are: "wallet" - for Google wallet permissions.|
|||redirectMethod||string||This parameter is only applicable when redirectURL is specified and it determines how the user info data is passed to the redirectURLs. This parameter accepts two values: |
|||redirectURL||string||This parameter is relevant only if the authFlow parameter is set to "redirect" (see above). Set this parameter with a URL to which to redirect the user when the adding connection process has successfully completed.|
The following additional parameters are appended to the URL string: UID, UIDSig, timestamp, loginProvider, loginProviderUID, nickname, photoURL, thumbnailURL, firstName, lastName, gender, birthDay, birthMonth, birthYear, email, country, state, city, zip, profileURL, provider.
When redirectURL is explicitly defined by the partner the user object fields should always be sent with the redirect regardless of the authFlow mode.
Note: We strongly recommend providing a secure Https URL.
|||sessionExpiration||integer||This parameter defines the time in seconds that Gigya should keep the social network session valid for the user. To end the session when the browser closes, please assign the value '0'. If this parameter is not specified the session will be valid forever.|
Response Object Data Members
|user||User object||A User object with updated information for the current user.|
Triggered Global Event
By using this method, the following global event is triggered: onConnectionAdded. To register an event handler use the socialize.addEventHandlers API method. Please refer to the onConnectionAdded event data. Refer to Events to learn more about how to handle events generated by the Gigya service.