Orkut Application Platform

On-Site Application Developer Guide: Activities

Contents

What are Activities?

The first thing users see when logging into Orkut is the list that shows the updates from their friends. Each individual update is called an "activity", and the feed is called an "activity stream".

Several actions on Orkut will post an activity to the user's stream: for example, joining a community, updating details on one's profile, posting photos amongst others.

Posting Activities

Applications can also post updates to the user's stream through the API. In order to do that, you must call OpenSocial's requestCreateActivity() function as the example below demonstrates.

function init() {
   var params = {};
   params[opensocial.Activity.Field.TITLE] = "This is the <b>activity title</b>.";
   params[opensocial.Activity.Field.BODY] = "This is the <em>activity body.</em>";

   opensocial.requestCreateActivity(opensocial.newActivity(params),
        opensocial.CreateActivityPriority.HIGH, callback);
}

function callback(data) {
   debug.say(data.hadError() ? 
      "*** Error: " + data.getErrorMessage() : "Success.");
}

gadgets.util.registerOnLoadHandler(init);

Notice that we are supplying two parameters to the activity creation: the title and the body. These are the only two possible fields for an Activity (the OpenSocial standard lists some more, but on Orkut those are the only ones). The priority parameter (here, we are supplying opensocial.CreateActivityPriority.HIGH as its value) controls the behavior in case the application is not allowed to post activities by default: if the priority is high, the user will be asked to grant permission; if priority is low, the activity will not be posted.

As the example demonstrates, you can include some simple HTML in your activity. However see the section below lists some issues to be aware of when using HTML, since there are some important restrictions.

When you call requestCreateActivity, a confirmation will be shown to the user:



Activity Confirmation Popup

If the user confirms your activity, you will receive a success result on your callback; if the user cancels, you will receive an error on your callback function. Notice that the user can also check the box to "Don't ask me again", in which case this confirmation dialog will stop showing and the user's last response will be permanent for all future activity posts.

Issues and Restrictions to Look Out For

There are some issues that you should be aware of when creating activities:

  • HTML sanitization: your HTML will be sanitized and rewritten, so only certain tags will be preserved. Particularly, any Javascript code will be removed.

  • Do not use animation: animation is not allowed in activity posts, as they are very distracting to the user and detract from his experience.

  • URL rewriting (proxy): in order to speed up rendering, most external resources referenced by your HTML will have their URLs rewritten to use our proxy servers. Amongst other things, this means it's not currently possible to insert a tracking pixel in an activity, since the tracking pixel's URL would be rewritten to go through our proxy.

  • Activities should only be posted when the user performs something relevant in your application. You should avoid posting too many activities, as that will decrease their value for the user. Orkut may impose limits to activity posting based on your usage pattern.

  • To prevent spam, Orkut may impose restrictions on the number of activities your application may post, and may filter activities when they are viewed in order to ensure a good user experience.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.