Getting OWNER/VIEWER's number of friends

Person objects don't have a field with its number of friends. Therefor we need a small workaround, which can determine the number of friends of the OWNER of VIEWER (if available).

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="friend count" summary="" description="" author="" author_email="" thumbnail="" screenshot="" height="380">
   <Require feature="opensocial-0.7"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript">
function init(){
	/* only interested in friendCount, not the actual friends */
	var params = {max: 1};
 
	var req = opensocial.newDataRequest();
	req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.OWNER_FRIENDS, params), 'owner_friends');
	req.send(callback);
}
function callback(dataResponse){
	var owner_friends = dataResponse.get('owner_friends').getData();
	/* owner_friends is of type Collection */
	var friendCount = owner_friends.getTotalSize();
}
gadgets.util.registerOnLoadHandler(init);
</script>
]]>
</Content>
</Module>

Example install (Make sure you're not in OpenSocial Sandbox mode)

Example file