Ning Developer Docs

Updating the Latest Activity Stream in Your Ning App

Having a Ning App write to the activity stream (using opensocial.requestCreateActivity) is the most effective way to drive visibility and traffic to your application directly from the main page of a social network.

We can see opensocial.requestCreateActivity in action by using the OpenSocial Dev App tool; you can install the OpenSocial Dev App tool on a Ning Apps sandbox by going to http://NETWORKNAME.ning.com/opensocial/ningapps/addByUrl to add an XML file manually (replacing NETWORKNAME with the name of your social network) and adding the url http://gadgetstore.ning.com/gadgets/coderunner/coderunner08.xml. Once the OpenSocial Dev App tool is installed, paste the following code into the development window:


function postActivity(text) {
var params = {};
params[opensocial.Activity.Field.TITLE] = text;
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());


The activity object is created through opensocial.newActivity(), and that object is placed -- along with a callback function -- as a parameter to the opensocial.requestCreateActivity method. The callback function is optional, and is specifically called after requestCreateActivity is invoked.

Now that you understand how to ping the Latest Activity stream, you can update your OpenSocial code appropriately to ping the latest activity feed on the main page.

NOTE: 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. With the exception of the <a>tag, all HTML is stripped from the text before the API is invoked due to abuse prevention purposes.

Views: 86

Comment

You need to be a member of Ning Developer Docs to add comments!

Join Ning Developer Docs

© 2024   Created by Ning Developer Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service