Publishes a user action to the newsfeed stream on all the connected providers that support this feature.
To learn more about publishing newsfeed items, please read Advanced Sharing.
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.publishUserAction.
The following providers currently support this operation: Facebook, Twitter, LinkedIn, VKontakte* , Tencent QQ, Renren and Sina Weibo.
Possible Responses and the "Unsupported Provider" Error
When publishUserAction is called, the Gigya server tries to publish the user action to every provider to which the user is connected that is also listed in the 'enabledProviders' parameter. If the server succeeds in publishing to at least one of these providers, it considers the operation successful. An error is returned only if the server cannot publish to any of these providers.
In other words, if you call publishUserAction and specify an unsupported provider in 'enabledProviders', the call might still succeed if the user has other valid connected providers -- or it may fail for other reasons, e.g. an expired session on a supported provider.
The server returns an 'unsupported provider' error only if the user is connected to that unsupported provider and has no other valid connections.
The following table lists the available parameters:
|UserAction object||The user action to publish.|
|||actionAttributes||JSON object||In Gamification your users receive points for actions they perform on your site, in this case publishing a user action 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 publishes a user action, 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.
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.
A comma-delimited list of provider names to exclude in the method execution. This parameter gives the possibility to specify providers to which you do not want this method to apply. If you do not set this parameter, by default, no provider is disabled (i.e., the method applies to all connected providers).'facebook' , 'twitter' , 'linkedin' , ' vkontakte', 'qq', 'renren', 'sina'.
For example, if you would like the method to apply to all providers except Twitter, define: disabledProviders: "twitter".
Valid provider names include:
A comma-delimited list of provider names to include in the method execution. This parameter gives the possibility to apply this method only to a subset of providers of your choice. If you do not set this parameter, by default all the providers are enabled (i.e., the method applies to all connected providers).'facebook' , 'twitter' , 'linkedin' , ' vkontakte' , 'qq', 'renren', 'sina' .
For example, if you would like the method to apply only to Twitter, define: enabledProviders: "twitter".
Valid provider names include:
The VKontakte application must be whitelisted in order for it to support share.
Using this parameter you may determine whether to use Gigya's URL shortening service for URLs passed in the status parameter. The optional values for this parameter are:
URL shortening requirements vary between providers and depend on the particular type of action and its content. URL shortening is available for the following providers:
When Gigya's URL shortening service is active, Gigya tracks all the traffic coming from the distributed URLs. In such case, 'Referred Traffic' reports will be available to you.
|||tags||string||A comma separated list of tags that are used to identify the share operation.|
|||UserAction||UserAction object||It is possible to specify a different content to publish for each social network. For this purpose, the method supports a set of parameters with the same name format: (i.e. facebook, twitter, etc.) followed by "UserAction". For example: twitter UserAction - specifies the content to be used specifically when publishing to Twitter.|
Each of these optional parameters accepts a UserAction object and if specified override the userAction parameter when publishing to that provider. In other words, the userAction parameter (see above) specifies the default content to be used for all social networks and UserAction specifies the content to be used for the specific network.
|||userLocation||JSON Object||The location to which this user action refers. Assigning a location to a user action is currently supported by Twitter only. The value of this parameter should be a JSON object containing the following fields:|
Response Object Data Members
|providerPostIDs||array||An array of JSON objects representing the social network's post ID. Each object has the following fields:|
In the Publish newsfeed stories you will find a complete working example that uses the socialize.publishUserAction method. You may view the code, run it and view the outcome.