Writing to the Activity StreamΒΆ
The following code will let an OpenSocial Application on Ning write to the Latest Activity module on a member’s profile page, provided that the Application is installed on your profile page and you are viewing it:
<script type="text/javascript">
function postActivity(text) {
var params = {};
params[opensocial.Activity.Field.TITLE] = text;
params[opensocial.Activity.Field.BODY] = "<a href='http://www.yahoo.com'>Hello World</a>";
var activity = opensocial.newActivity(params);
opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH, callback);
};
function callback(data) {
/* callback is an optional function which is called after requestCreateActivity. */
/* do what you would like with the data attribute. */
document.getElementById("dom_handler").innerHTML = "Latest activity will be shown when you refresh your profile page.";
};
postActivity("This is a sample activity, created at " + new Date().toString());
</script>
<div id="dom_handler"></div>
The requestCreateActivity API has a quota of 5 invocations per member, per application, per day. This means that a member can call the functionality five times a day for each application. New Activity Feed data can only be written to a member’s Profile Page, not the main page of a Ning Network. With the exception of the <a> tag, all HTML is stripped from the text before the API is invoked.
No HTML is allowed when writing to the Activity Stream.