Hi, all,
I've got into some trouble with newFetchActivitiesRequest, even did I
paste the code in
http://code.google.com/apis/opensocial/docs/0.6/devguide.html#Activities
gadgets.util.registerOnLoadHandler(getActivities);
function getActivities() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
req.add(req.newFetchActivitiesRequest('VIEWER'),
'viewerActivities');
req.add(req.newFetchActivitiesRequest('VIEWER_FRIENDS'),
'friendActivities');
req.send(showActivities);
}
function showActivities(dataResponse) {
var viewer = dataResponse.get('viewer').getData();
var viewerActivities = dataResponse.get('viewerActivities').getData()
['activities'];
var friendActivities = dataResponse.get('friendActivities').getData()
['activities'];
var htmlout = '';
htmlout += '<h2>Your activities:</h2><br>';
htmlout += getActivitiesHtml(viewerActivities);
htmlout += '<h2>Your friends\' activities:</h2><br>';
htmlout += getActivitiesHtml(friendActivities);
document.getElementById('read_activities').innerHTML = htmlout;
}
function getActivitiesHtml(stream) {
console.log(stream);
var htmlout = '';
stream.each(function(activity) {
var link = activity.getField('url');
if (link) {
htmlout += '<a href="' + link +'" target="_blank">'+
activity.getField('title') + '</a>';
} else {
htmlout += activity.getField('title');
}
htmlout += '<br>';
});
return htmlout;
}
function writeActivity() {
var streamFolder = 'sampleFolder';
var streamTitle = 'Sample Stream';
var stream_params = {'url': 'http://samplestream.com' };
var stream = opensocial.newStream(streamFolder, streamTitle,
stream_params);
var title = document.getElementById('title').value;
var link = document.getElementById('link').value;
var activity_params = {'url' : link}
var activity = opensocial.newActivity(stream, title,
activity_params)
opensocial.requestCreateActivity(activity, "HIGH", getActivities);
}
</script>
<div id="write_activities">
Title:<input id="title" /><br>
Link:<input id="link" /><br>
<input type="button" value="add activity" onclick="writeActivity
();" />
</div>
<div id="read_activities">
</div>
and try "view development version", the activities still cannot be
shown.
I've caught this error in error console.
Error: dataResponse.get("viewerActivities") is undefined
Can somebody tell me why this happen? Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Orkut Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/opensocial-orkut?hl=en
-~----------~----~----~----~------~----~------~--~---