O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Personalizing an Application Experience by Consuming Activity Updates

Whereas the user’s profile comprises the data that she chooses to share and reflects how she sees herself, the user’s activity stream shows the reality of what that user does and likes. The activity stream contains information such as application installs, application updates, status and profile information, as well as a gold mine of additional data, all of which can give you insight into the user’s online habits, likes, and dislikes. When used in conjunction with the user’s profile information, the activity stream gives a developer a great opportunity to target content and advertising directly to that user.

The defining truth in any social network is the user’s activity stream. When the user sends messages, the person she’s contacting, what she’s doing, and what applications she’s using all become accessible to a developer via the activity stream.

OpenSocial defines a standard method for capturing these user details:

//capture viewer activities
osapi.activities.get({userId: '@viewer ', count: 20}).execute(function(result){
  if (!result.error){
    var activities = result.list;
    var html = ' ';

    //build title and url for each discovered activity
    for (var i = 0; i < activities.length; i++){
      html += 'Activity Title: ' + activities[i].title +
          'Activity URL: ' + activities[i].url;
    }
  }
});

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required