programmaticPluginTrigger.md

Manually triggering a plugin

A plugin can be triggered manually in the following cases:

1. The plugin has its behaviour set to manual.
2. The plugin has its display mode set to none.

Plugins with behaviour set to manual

The plugin will not be triggered automatically. Instead it will be triggered programmatically only when the triggerPlugin() function is called.

Once triggered manually, all plugin rules apply and the plugin flow is identical to the others.

The function should be used as follows:

 socital.triggerPlugin(pluginID, callback)

Example

Example request:

 socital.triggerPlugin("5878d05ea253ce85c139653d",function(err,data){if (err) {console.log('Error: '+err)} else {console.log(JSON.stringify(data))}})

…in case of a successfull login, the data parameter in the callback function will contain an object of the following type:

 {     "success":true,   "socialUser":"{\"id\":\"...\",\"name\":\"...\",\"email\":\"...\",\"provider\":\"linkedin\",\"pluginID\":\"5878d05ea253ce85c139653d\"}"}

In case of an unsuccessfull login, the err parameter in the callback function will contain an object of the following type:

 xxxxxxxxxx{  success: false,   error: "Authentication error."}

Plugins with display mode set to none.

The plugin will not be triggered automatically, and it can't be shown at all when triggered (its contents are always completely hidden to the user).

Once triggered manually, the plugin will show just the social network login dialog. At login success or failure, the given callback function is called.

The function should be used as follows:

 socital.triggerPlugin(pluginID, provider, data, callback)

Example

By performing the following example call:

 socital.triggerPlugin("5878d05ea253ce85c139653d","linkedin",{dataToPassBack:1},function(err,data){  if (err) {    console.log('Error: '+err)  }   else {    console.log(JSON.stringify(data))  }})

…in case of a successfull login, the data parameter in the callback function will contain an object of the following type:

 {     "success":true,   "socialUser":"{\"id\":\"...\",\"name\":\"...\",\"email\":\"...\",\"provider\":\"linkedin\",\"pluginID\":\"5878d05ea253ce85c139653d\"}",   "forwardData":{        "dataToPassBack":1 // Data passed back to you   }}

In case of an unsuccessfull login, the err parameter in the callback function will contain an object of the following type:

 x{  success: false,   error: "Authentication error."}