So I'm trying to write my first app, but keep stumbling at the first step. I've followed the example (http://wiki.developer.myspace.com/index.php?title=Example_Application:_Hello_World),and pasted this exact code into my profile surface.
<div id='heading'></div>
<hr size="1px" />
<script type="text/javascript">
var os;
var dataReqObj;
var heading = null;
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) {
var viewer = data.get(opensocial.DataRequest.PersonId.VIEWER).getData();
heading = 'Hello, ' + viewer.getDisplayName();
document.getElementById('heading').innerHTML = heading;
}
init();
</script>
However, as soon as I run it, there's a JS error saying, "opensocial is not defined". So the app fails. I keep getting the same with "gadgets" too.I can see in the <head> that the javascript is all included, but it's still not working.
Now I'm a pretty experienced coder, and wonder whatuber-simple mistakeI'm making?!! Arrrgh, it's so frustraiting!