UserAction JS

Skip to end of metadata
Go to start of metadata

 

Description

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.

 

Note: A shared URL must match the approved URLs (domains) for the specified API key, otherwise the share will not work. 

 

Constructor

UserAction()

Creates a new UserAction instance.

For example:

var act = new gigya.socialize.UserAction();  

 

Member Methods 

RequiredMethod Name Description
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>.

Note: When using the Share add-on (socialize.showShareUI and socialize.showShareBarUI), the user message is not supported. Preset user messages are contrary to Facebook developer guidelines.

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.

Parameters:
   title - link's text.
   href - link URL. Note: the URL must be an absolute URL.

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.

Media Object

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:

Field NameTypeDescription
typestringThe media type. The valid values for this field are: 'image', 'flash' or 'mp3'.
srcstringThe 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:

type: 'image'

Field NameTypeDescription
hrefstringURL of a link to associate with the image. Must be a valid URL that starts with "http".

type: 'flash'

Field NameTypeDescription
widthnumberThe width of the Flash object to be rendered.
heightnumberThe height of the Flash object to be rendered.
previewImageURLURLThe 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.
previewImageWidthnumberThe width of the preview image.
previewImageHeightnumberThe height of the preview image.

type: 'mp3'

Field NameTypeDescription
titlestringThe "Title" property of the mp3 file.
artiststringThe "Artist" property of the mp3 file.
albumstringThe "Album" property of the mp3 file.

Usage Examples

Refer to the socialize.publishUserAction Code sample for a typical usage of the UserAction object. 

Sharing Limitations

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

  • Twitter
    • 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.
  • LinkedIn
    • 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).
  • Facebook
    • 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).

 

For more information please see Advanced Sharing socialize.showShareBarUI.