Opensocial.Activity (v0.9)

From VZ Developer Wiki
Revision as of 12:11, 29 July 2010 by Seba (talk | contribs) (Created page with '{{NeedsExamples}} <div style="float:right; margin: 0 0 10px 10px;">__TOC__</div> <span style="font-size:150%"><strong>opensocial.Activity</strong></span> Representation of an a…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This documentation is not completed yet and will be extended by more examples in future.

opensocial.Activity

Representation of an activity. Activities are rendered with a title and an optional activity body. You may set the title and body directly as strings when calling opensocial.newActivity. However, it is usually beneficial to create activities using Message Templates for the title and body. Users will have many activities in their activity streams, and containers will not show every activity that is visible to a user. To help display large numbers of activities, containers will summarize a list of activities from a given source to a single entry. You can provide Activity Summaries to customize the text shown when multiple activities are summarized. If no customization is provided, a container may ignore your activities altogether or provide default text such as "Bob changed his status message + 20 other events like this."

Activity Summaries will always summarize around a specific key in a key/value pair. This is so that the summary can say something concrete (this is clearer in the example below). Other variables will have synthetic "Count" variables created with the total number of items summarized. Message ID of the summary is the message ID of the main template + ":" + the data key

Example summaries:

<messagebundle> 
 <msg name="LISTEN_TO_THIS_SONG:Artist"> 
  ${Subject.Count} of your friends have suggested listening to songs by ${Artist}! 
 </msg> 
 <msg name="LISTEN_TO_THIS_SONG:Song"> 
  ${Subject.Count} of your friends have suggested listening to ${Song}!
 </msg> 
 <msg name="LISTEN_TO_THIS_SONG:Subject"> 
  ${Subject.DisplayName} has recommended ${Song.Count} songs to you. 
 </msg> 
</messagebundle>

See also: opensocial.Message, opensocial.newActivity, opensocial.requestCreateActivity

Methods

opensocial.Activity.getField

String getField(key, opt_params)
Parameters
Name Type Description
key String The key to get data for; see the Field class for possible values
opt_params Map.<opensocial.DataRequest.DataRequestFields|Object> Additional params to pass to the request.
Returns
Type Description
String The data
Description
Gets the activity data that's associated with the specified key.

opensocial.Activity.getId

String getId()
Returns
Type Description
String The ID
Description
Gets an ID that can be permanently associated with this activity.

opensocial.Activity.setField

setField(key, data)
Parameters
Name Type Description
key String The key to set data for
data String The data to set
Description
Sets data for this activity associated with the given key.

opensocial.Activity.Field

All of the fields that activities can have. It is only required to set one of TITLE_ID or TITLE. In addition, if you are using any variables in your title or title template, you must set TEMPLATE_PARAMS. Other possible fields to set are: URL, MEDIA_ITEMS, BODY_ID, BODY, EXTERNAL_ID, PRIORITY, STREAM_TITLE, STREAM_URL, STREAM_SOURCE_URL, and STREAM_FAVICON_URL. Containers are only required to use TITLE_ID or TITLE, they may ignore additional parameters. See also: opensocial.Activity.getField()

opensocial.Activity.Field.APP_ID

A string specifying the application that this activity is associated with. This value can not be set. This field may be used interchangeably with the string 'appId'.

opensocial.Activity.Field.BODY

A string specifying an optional expanded version of an activity. Bodies may only have the following HTML tags: <b> <i>, <a>, <span>. The container may ignore this formatting when rendering the activity. This field may be used interchangeably with the string 'body'. See Container Activity filters

opensocial.Activity.Field.BODY_ID

A string specifying the body template message ID in the gadget spec. The body is an optional expanded version of an activity. Bodies may only have the following HTML tags: <b> <i>, <a>, <span>. The container may ignore this formatting when rendering the activity. This field may be used interchangeably with the string 'bodyId'.

opensocial.Activity.Field.EXTERNAL_ID

An optional string ID generated by the posting application. This field may be used interchangeably with the string 'externalId'.

opensocial.Activity.Field.ID

A string ID that is permanently associated with this activity. This value can not be set. This field may be used interchangeably with the string 'id'.

opensocial.Activity.Field.MEDIA_ITEMS

Any photos, videos, or images that should be associated with the activity. Higher priority ones are higher in the list. The data has type Array< MediaItem >. This field may be used interchangeably with the string 'mediaItems'.

opensocial.Activity.Field.POSTED_TIME

A string specifying the time at which this activity took place in milliseconds since the epoch. This value can not be set. This field may be used interchangeably with the string 'postedTime'.

opensocial.Activity.Field.PRIORITY

A number between 0 and 1 representing the relative priority of this activity in relation to other activities from the same source This field may be used interchangeably with the string 'priority'.

opensocial.Activity.Field.STREAM_FAVICON_URL

<static> Member of: opensocial.Activity.Field.STREAM_FAVICON_URL This field may be used interchangeably with the string 'streamFaviconUrl'.

opensocial.Activity.Field.STREAM_SOURCE_URL

<static> Member of: opensocial.Activity.Field.STREAM_SOURCE_URL This field may be used interchangeably with the string 'streamSourceUrl'.

opensocial.Activity.Field.STREAM_TITLE

A string specifing the title of the stream. This field may be used interchangeably with the string 'streamTitle'.

opensocial.Activity.Field.STREAM_URL

A string specifying the stream's URL. This field may be used interchangeably with the string 'streamUrl'.

opensocial.Activity.Field.TEMPLATE_PARAMS

<static> Member of: opensocial.Activity.Field.TEMPLATE_PARAMS A map of custom key/value pairs associated with this activity. These will be used for evaluation in templates. The data has type Map<String, Object>. The object may be either a String or an opensocial.Person. When passing in a person with key PersonKey, can use the following replacement variables in the template: <list style="symbols"> PersonKey.ProfileUrl. URL of the person's profile PersonKey.Id - The ID of the person PersonKey - Container may replace with DisplayName, but may also optionally link to the user. </list> This field may be used interchangeably with the string 'templateParams'.

opensocial.Activity.Field.TITLE

A string specifying the primary text of an activity. Titles may only have the following HTML tags: <b> <i>, <a>, <span>. The container may ignore this formatting when rendering the activity. This field may be used interchangeably with the string 'title'.

opensocial.Activity.Field.TITLE_ID

A string specifying the title template message ID in the gadget spec. The title is the primary text of an activity. Titles may only have the following HTML tags: <b> <i>, <a>, <span>. The container may ignore this formatting when rendering the activity. This field may be used interchangeably with the string 'titleId'.

opensocial.Activity.Field.URL

A string specifying the URL that represents this activity. This field may be used interchangeably with the string 'url'.

opensocial.Activity.Field.USER_ID

The string ID of the user who this activity is for. This value can not be set. This field may be used interchangeably with the string 'userId'.



OpenSocial (v0.9)

gadgets

gadgets.io

gadgets.json

gadgets.Prefs

gadgets.util

gadgets.views

gadgets.flash

gadgets.MiniMessage

gadgets.oauth.Popup

gadgets.rpc

gadgets.skins

gadgets.pubsub

gadgets.Tab

gadgets.TabSet

gadgets.window

gadgets.i18n

opensocial

opensocial.Activity

opensocial.Address

opensocial.Album

opensocial.BodyType

opensocial.Collection

opensocial.CreateActivityPriority

opensocial.DataRequest

opensocial.DataResponse

opensocial.Email

opensocial.Enum

opensocial.Environment

opensocial.EscapeType

opensocial.IdSpec

opensocial.MediaItem

opensocial.Message

opensocial.MessageCollection

opensocial.Name

opensocial.NavigationParameters

opensocial.Organization

opensocial.Permission

opensocial.Person

opensocial.Phone

opensocial.ResponseItem

opensocial.Url

osapi.Request

osapi.BatchRequest

osapi.people

osapi.activities

osapi.appdata

osapi.messages

osapi.http