Table of contents
Description
Publishes a user action to the newsfeed stream on all the connected providers that support this feature.
To learn more about publishing newsfeeds, please read the Advanced Sharing page in the Developer's Guide.
Note: This method is also supported in our REST API. If you wish to execute this method from your server, please refer to REST API > socialize.publishUserAction.
Supporting Providers
The following providers currently support this operation: Facebook, Twitter, Yahoo, LinkedIn, Myspace, Orkut, VKontakte*, Yahoo Japan, Tencent QQ, Renren and Sina Weibo. *Note: the VKontakte application must be whitelisted in order for it to support share.
Note: Before your application can publish to Facebook, the user must grant your application an extended permission. Please make sure you have checked the "Enable Wall Updates" check box in the Site Setup > Permissions page on Gigya's website. During the social login process, the user is presented with a dialog in which the user can authorize your application to publish to her Facebook profile.
Read more in the the Facebook Setting - Permissions guide.
Syntax
gigya.socialize.publishUserAction(params)
Method Parameters
The following table lists the params object members:
| Required | Name | Type | Description |
| Required | userAction | UserAction object | The user action to publish. |
| Optional | callback | function | 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. |
| enabledProviders | string | 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). For example, if you would like the method to apply only to Facebook and Twitter, define: enabledProviders="facebook,twitter". Valid provider names include: 'facebook', 'twitter', 'yahoo', 'google', 'linkedin', 'myspace', 'orkut', 'vkontakte'*, 'yahoojapan', 'qq', 'renren', 'sina'. Note: the value of this parameter overrides the value of the identical parameter in the global configuration object. | |
| disabledProviders | string | A comma-delimited list of provider names to exclude in the method execution. This parameter gives the possibility to specify providers to which that you don't 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). For example, if you would like the method to apply to all providers except Google and Twitter, define: disabledProviders="google,twitter". Valid provider names include: 'facebook', 'twitter', 'yahoo', 'google', 'linkedin', 'myspace', 'orkut', 'vkontakte'*, 'yahoojapan', 'qq', 'renren', 'sina'. Note: the value of this parameter overrides the value of the identical parameter in the global configuration object. | |
| <provider-name>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: <provider-name> (i.e. facebook, twitter, yahoo, etc.) followed by "UserAction". For example: twitterUserAction - 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 <provider-name>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:
| |
| cid | string | A string of maximum 100 characters length. This string is associated with each transaction and will later appear on 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. The "Context ID" combo box lets you filter the report data by site/application context. Note: the value of this parameter overrides the value of the identical parameter in the global configuration object. | |
| shortURLs | string | Using this parameter you may determine whether to use Gigya's URL shortening service for URLs, which are published through this method. The optional values for this parameter are:
Note: the value of this parameter overrides the value of the identical parameter in the global configuration object. | |
| context | object | A developer-created object that is passed back unchanged to the application as one of the fields in the response object. | |
| 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. These action attributes are later used to display the GM Plugins filtered according to a certain attribute. For example, you can show the Leaderboard plugin only for top users on the "Glee" page. This parameter receives a JSON object, comprised of a set or sets of a key (category) and a value or values, i.e.: "tv-show": ["glee", "30rock"], | |
| tags | string | A comma separated list of tags that are used to identify the share operation. | |
| Activity Feed Plugin related Parameters: The following parameters are relevant only if you are integrating the Activity Feed Plugin in your site | |||
| scope | string | When publishing feed items, by default the feed items are published to social networks only and will not appear on the site's Activity Feed plugin. To change this behavior, you must change the publish scope. The optional values for this parameter are:
| |
| privacy | string | The privacy level determines how the user action is presented in each of the Activity Feed plugin tabs. The optional values for this parameter are:
| |
| feedID | string | The purpose of this parameter is to support multiple Feed Streams with different feeds on the same domain. You may give a different feedID to different Activity Feed plugins in your site. The Activity Feed plugin shows only User Actions that are published with the same feedID (please refer to the same parameter in the showFeedUI method). Using this parameter you may choose to which Activity Feed plugin on your site this User Action will be published. If this parameter is not set, it will be published on an Activity Feed plugin that has no feedID (default). | |
Response Object Data Members
| Field | Type | Description |
| errorCode | integer | The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Error Codes table. |
| errorMessage | string | A short textual description of an error associated with the errorCode for logging purposes. |
| operation | string | The name of the API method that generated this response. |
| context | object | The context object passed by the application as parameter to the API method, or null if no context object has been passed. |
| providerPostIDs | array | An array of JSON objects representing the social network's post ID. Each object has the following fields:
|
Code Sample
// Constructing a UserAction Object
var act = new gigya.socialize.UserAction();
act.setTitle("This is my title"); // Setting the Title
act.setLinkBack("http://www.gigya.com"); // Setting the Link Back
act.setDescription("This is my Description"); // Setting Description
act.addActionLink("Read More", "http://www.gigya.com"); // Adding Action Link
// Adding a Media (image)
act.addMediaItem( { type: 'image', src: 'http://www.infozoom.ru/wp-content/uploads/2009/08/d06_19748631.jpg', href: 'http://www.gigya.com' });
var params =
{
userAction:act
};
// Publishing the User Action
gigya.socialize.publishUserAction(params); - This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
- To run the code on your own domain, add your Gigya API key to the socialize.js URL. A Gigya API key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API key.
- In some cases it is necessary to connect/login the user to a provider? prior to calling the API method. You can learn more in the Social Login guide.
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.

Comments