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;
}
}
});Note
The full code for this sample is available at https://github.com/jcleblanc/programming-social-applications/blob/master/chapter_6/activities_capture.js ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access