Skip to content

Instantly share code, notes, and snippets.

@jfahrenkrug
Created February 16, 2009 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfahrenkrug/65067 to your computer and use it in GitHub Desktop.
Save jfahrenkrug/65067 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs
title="Owner ID Test"
height="600">
<Require feature="opensocial-0.7"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<script src="http://www.google.com/jsapi"></script>
<script>google.load("jquery", "1.2.6");</script>
<script>
// owner id
var ownertest = function() {
var that = {
getOwner : function() {
var req = opensocial.newDataRequest();
var params = {};
params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=[opensocial.Person.Field.GENDER, opensocial.Person.Field.PROFILE_URL];
req.add(req.newFetchPersonRequest("OWNER", params), "owner");
req.send(that.getOwnerCallback);
},
getOwnerCallback: function(data) {
if (data.get("owner").hadError()) {
console.log("setupViewerOwnerIdsCallback had error");
} else {
var owner = data.get("owner").getData();
var owner_id = owner.getId();
var owner_network_uid = '';
//Orkut specific
if (opensocial.getEnvironment().getDomain() == 'orkut.com') {
var profile_url = owner.getField(opensocial.Person.Field.PROFILE_URL);
var regex = /uid=([^&#]+)/;
var result = profile_url.match(regex);
if (result.length == 2) {
owner_network_uid = result[1];
/* uid now contains the viewer's orkut UID */
} else {
/* there was a problem getting the UID */
}
}
$('#owner-span').html(owner_id);
$('#owner-uid-span').html(owner_network_uid);
}
}
};
return that;
}(); //notice that the function is invoked right away
gadgets.util.registerOnLoadHandler(ownertest.getOwner);
</script>
<h2>Owner ID</h2>
<p>The owner has the id <span id="owner-span"></span>!</p>
<h2>Owner Orkut UID</h2>
<p>The owner has the orkut uid <span id="owner-uid-span"></span>!</p>
<p>(2009, <a href="http://blog.springenwerk.com">Johannes Fahrenkrug</a>)</p>
]]>
</Content>
</Module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment