This has became a major annoyance for me. Because of this problem (and this problem: http://developer.myspace.com/Community/forums/t/10014.aspx), I was forced to investigate other ways of displaying external content, with this documentation (http://wiki.opensocial.org/index.php?title=Remote_Data_Requests_%28v0.9%29) as my guide.
In the end I used makeRequest, and I THOUGHT my app was working, but it appears to only work for
those with the app installed. Everybody else just sees a blank screen,
which is no good. My code is below, can somebody please tell me where I am going wrong? Essentially I need to be able to do two things:
1) Detect the owner
2) Display the appropriate external content, based on the owner's preferences.
And it must work for logged out viewers.
<style>
#target { overflow:auto; }
</style>
<div id="target"></div>
<script type="text/javascript">
function init() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER), 'owner');
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer');
req.send(viewerResponse);
}
function viewerResponse(data) {
var owner = data.get("owner").getData();
var viewer = data.get("viewer").getData();
url = 'http://example.com/index.php?view=PROFILE&owner='+owner.getId()+'&viewer='+viewer.getId();
navigateApp(url);
}
function navigateApp(url) {
var req_params = new Object();
req_params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
req_params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
var req = gadgets.io.makeRequest(url, signRequestCompleted, req_params);
}
function signRequestCompleted(data) {
var target = document.getElementById('target');
target.innerHTML = data.text;
target.style.height = 'auto';
gadgets.window.adjustHeight();
target.style.height = '100%';
}
function getViewName() {
return gadgets.views.getCurrentView().getName();
}
function loadPage(url,num) {
navigateApp(url);
return false;
}
function submitForm(url) {
var venue = document.getElementById('venue').value;
url = url + '&venue=' + venue;
navigateApp(url);
return false;
}
gadgets.util.registerOnLoadHandler(init);
</script>
I thought that maybe because the viewers ID was unknown, the call to newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER) may have been failing. But removing this made no difference.
Any help would be greatly appreciated.