Day 1: First MySpace / OpenSocial app

Have been playing all day, not fruitlessly but not as much fruit as I would have liked with creating a MySpace profile app, this one should simply print the name of the user viewing the app, the name of the user who has the app installed and whether or not the viewer has the app installed within their profile. From there on the user should be able to be prompted to add the app for themselves. Although its not quite working I should be there in a few more hours.

<script type="text/javascript" src="http://api.msappspace.com/AppRendering/js/jquery-1.2.1.min.js"></script>

<style type="text/css">
  div#widget {
    width: 300px;
    background-color: #bee0ed;
  }
  div#widget img {
    margin: 14px;
  }
</style>
<div id="widget">
  <img src="http://devsite/layout/logo.png" alt="My Site" class="logo" />
  <div id="viewer">
  </div> 
  <div id="owner">
  </div> 

</div>

<script type="text/javascript">
 
var os;
var dataReqObj;
var dataReqObj2;
var heading = null;
var viewer = null;

var v = opensocial.IdSpec.PersonId.VIEWER;
var o = opensocial.IdSpec.PersonId.OWNER;

function init() {
    os = opensocial.Container.get();
    
    var params = {};
    params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [opensocial.Person.Field.HAS_APP];

    dataReqObj = os.newDataRequest();
    var viewerReq = os.newFetchPersonRequest(v, params);
    dataReqObj.add(viewerReq);
    dataReqObj.send(viewerResponse);

    dataReqObj2 = os.newDataRequest();
    var viewerReq2 = os.newFetchPersonRequest(o);
    dataReqObj2.add(viewerReq2);
    dataReqObj2.send(ownerResponse);
}

function viewerResponse(data) {
    var viewer = data.get(v).getData();
    heading = 'Hello, ' + viewer.getDisplayName();
    var has_app = viewer.getField(opensocial.Person.Field.HAS_APP);
    heading += has_app;
    if (has_app) {
       heading += '<p>You have this app</p>';
    }
    document.getElementById('viewer').innerHTML = heading;
}

function ownerResponse(data) {
    var viewer = data.get(o).getData();
    heading = 'Hello, ' + viewer.getDisplayName();
    document.getElementById('owner').innerHTML = heading;
}

init();

</script>