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;
    }
  }
});

In this request, we are making a call to osapi.activities.get(...), indicating that we want to return someone’s activity stream. The JSON object provided as the parameter to this request denotes that we want the activities for a userId that matches that of the current application viewer, and we want to return only 20 activities.

Once this request completes, we can parse each activity and use it however we’d like.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.153.212