Could someone please post a code snippet that successfully pulls from an external URL into the canvas? I've seen that a lot of people have this working, so perhaps this is just a temporary platform glitch?
This "sample code" called "working app 2" does not work from the canvas.
The alert pops up with "http://www.msappspace.com" only, not the content of the external page.
from http://developer.myspace.com/community/opensocial/create_app.aspx
<script>
function init()
{
var url = "http://www.w3.org";
os_params = {};
opensocial.makeRequest(url, makeRequest_Callback, os_params);
function makeRequest_Callback(data){
var responseText = data.responseText;
alert(responseText);
}
}
init();
</script>
So I look to this implementation details forum thread and I try to use myspaceseattlemax's code, from the first post of this thread, as
<div id="output"></div>
Point1
<script>
function init() {
var url = "http://www.w3.org";
os_params = {};
os_params[opensocial.ContentRequestParameters.METHOD] = opensocial.ContentRequestParameters.MethodType.GET;
opensocial.makeRequest(url, makeRequest_Callback, os_params);
}
function makeRequest_Callback(response, error) {
var content = response.responseText;
document.getElementById("output").innerHTML += "<br />" + content;
document.getElementById("output").innerHTML += "<br />" + "Point2";
}
init();
</script>
This prints Point1 and Point2, but only prints Undefined as the content of the url.
I'm seeing this as one error:
/relay.proxy?opensocial_token=MIGnBgorBgEEAYI3WAOYoIGYMIGVBgorBgEEAYI3WAMBoIGGMIGDAgMCAAECAmYDAgIAwAQIMDaRULVx%2bKcEEHS8atNhlCahsWX7VTxD%2bSUEWPhBnsJgEW7tifAZDaPMRsnrLhUZu28aJuts%2f6yaOLbehr0sRF6T%2fZ%
Separately, the code tester on http://developer.myspace.com/community/opensocial/create_app.aspx always gives me the "enter application code" error in red.