I am trying to create an opensocial.DataRequest from within an iFrame running on my locahost, but the call is getting mangled.
The Request call ends up pointing to this URL:
"http://localhost/OpenSocial/opensocial/v1/OWNER/profile.JSON?opensocial_token={TOKEN}&opensocial_surface=canvas&detailtype=BASIC"
But, of course, that won't work. Is the opensocial.DataRequest only supposed to work for MS Apps that are running ON MySpace?
The code I am using is EXACTLY what is demoed (and working) on the opensocial tool page for "Example: Hello Me"
http://developer.myspace.com/modules/apis/pages/opensocialtool.aspx
var os;
var dataReqObj;
var html = '';
var heading = '';
function init() {
os = opensocial.Container.get();
dataReqObj = os.newDataRequest();
var viewerReq = os.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER);
dataReqObj.add(viewerReq);
dataReqObj.send(viewerResponse);
}
function viewerResponse(data) {
if (data.hadError()) {
var data2 = data.get(opensocial.DataRequest.Group.VIEWER_FRIENDS);
alert(data2.getErrorCode() + '\n' + data2.getErrorMessage());
} else {
var viewer = data.get(opensocial.DataRequest.PersonId.VIEWER).getData();
var heading = 'Hello, ' + viewer.getDisplayName();
var thumb = viewer.getField(opensocial.Person.Field.THUMBNAIL_URL);
var profile = viewer.getField(opensocial.Person.Field.PROFILE_URL);
document.getElementById('heading').innerHTML = heading;
document.getElementById('main').innerHTML = html;
document.getElementById('loading').style.display = 'none';
}
}
My
end goal for this whole thing is to be able to verify that the ownerid
being passed into my iFrame hasn't been altered by the user. I need to
get the current logged in user's ID from MySpace (since I can't
securely rely on the query params passed into the iFrame)