The UserAction object represents a user action. The UserAction object is used for publishing actions using the socialize.showShareBarUI, socialize.showShareUI, socialize.publishUserAction and other Sharing related API methods. The UserAction object is constructed by the application. See the constructor description below for an example on how to construct a UserAction object. To learn more about using the UserAction object, read the Share Content guide.
Note: The userAction object is used to explicitly define characteristics for a share post item. It is recommended to implement open-graph tags in your page in addition to the userAction object, as some social networks use the og tags for the info, such as Facebook, Twitter and Google+. It is only possible for users to publish from domains which you have added to your approved list, for more information see Approved URLs.
Creates a new UserAction instance.
|||setUserMessage(userMessage)||Sets the "User Message" string of the User Action. The User Message is typically text entered by the user.|
The user message should consist of simple text only. Gigya will remove any HTML tags from the user message string, excluding the following tags: <b>, <i>, <u>, <strong>, <br>, <p>.
|||setLinkBack(href)||Sets the Linkback URL of the User Action. The Linkback is a link, typically to the content source. Note: the URL must be an absolute URL.|
|||addMediaItem(mediaObject)||Adds a media (Images \ Flash \ Mp3 \ Video) to the User Action. The method receives a mediaObject parameter, which is a JSON-encoded object containing the media's type and data. To learn more about using this method, please refer to the Adding Media Item/s to the UserAction Object section.|
|||addActionLink(title, href)||Adds a link that will appear in the links' area at the bottom of the post.|
|||setTitle(title)||Sets the Title string of the User Action. Typically this is the title of the posted content.|
|||setSubtitle(subtitle)||Sets the Subtitle string of the User Action. Typically this is mapped to the caption field of the post. Currently supported only by Facebook.|
|||setDescription(description)||Sets the Description string of the User Action. Typically this is the textual content of the post.|
|||setActionName(actionName)||Previously used with Activity Feed (deprecated).|
|||clone()||Creates and returns a copy of a UserAction object. This can be very useful when setting provider-specific UserAction content.|
A JSON-encoded object containing information about a media. The Media object structure depends on its type. All media objects include the following basic fields:
|type||string||The media type. The valid values for this field are: '|
|src||string||The URL to the media source. Must be a valid URL that starts with "http".|
The following subsections elaborate on the set of fields of each Media type:
|href||string||URL of a link to associate with the image. Must be a valid URL that starts with "http".|
|width||number||The width of the Flash object to be rendered.|
|height||number||The height of the Flash object to be rendered.|
|previewImageURL||URL||The URL of a photo that should be displayed in place of the Flash object until the user clicks to prompt the Flash object to play.|
|previewImageWidth||number||The width of the preview image.|
|previewImageHeight||number||The height of the preview image.|
|title||string||The "Title" property of the mp3 file.|
|artist||string||The "Artist" property of the mp3 file.|
|album||string||The "Album" property of the mp3 file.|
Refer to the socialize.publishUserAction Code sample for a typical usage of the UserAction object.
It is important to note that there are certain limitations on data size imposed by the various Social Networks, e.g., the combined character length of all parameters. This limitation can be anywhere from 140 characters in length for Twitter and up to 10,000 characters for Facebook. It is important to parse your data accordingly for the individual Social Network you are posting the information to.
Site Specific Limitations
- When sharing to Twitter, there are a couple of unique situations to be aware of. One is the hard limit of 140 characters including any spaces, user handle, etc. The second is that most URL's will be wrapped within a t.co wrapper which, in many cases may decrease the character count of the tweet, however, in some cases, such as when the original URL is extremely short to begin with, the character count may actually increase when wrapping it within the wrapper (depending on your settings within your Twitter app). If the ending character count of the tweet after having the URL wrapped upon arrival to twitter is greater than 140 characters, the share will fail, even if it was within the 140 character limit prior to leaving your server.
- setTitle(title) should be no more than 200 characters.
- setDescription(description) should be no more than 256 characters.
- *setUserMessage(userMessage) or comment - should be no more than 700 characters. Note that this should contain simple text only and Gigya will remove any HTML (see above).
- A status update can be up to 420 characters in length (all fields combined).
- A wall post, that contains either an attachment or an action link, can be up to 10,000 characters in length (all fields combined).
- (Note that there have been certain WordPress plugins reported to have bugs which can sometimes cause shares to fail due to exceeding the 10k limit, even though the original content is not actually 10k. Please review the documentation of your particular plugin or contact WordPress support if you are encountering a similar issue).