MySpace Developer Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in
Blogs from the OpenSocial JS Container Team

Container Team Updates: 04/24/2008

Hello all, we rolled a few additions and updates this morning - here is a summary.

Lightweight Calls

We’ve added some lightweight calls so you don’t have to get huge extended person objects.

 

Note:  id can be owner or viewer and the opt_params parameter is currently not used.

Indicators

[edit: proper way to access] 

MyOpenSpace.DataRequest.newFetchIndicatorsRequest(id, opt_params)

Moods

[edit: proper way to access] 

MyOpenSpace.DataRequest.newFetchPersonMoodRequest(id, opt_params)

Status

[edit: proper way to access] 

MyOpenSpace.DataRequest.newFetchPersonStatusRequest(id, opt_params)

 

Note: The enums that are currently used to access the results may change, but we'll give ample notice before any change is made and will remain backwards compatible for a time before removal. example: MyOpenSpace.Group.VIEWER_STATUS

 

Post To

We made a few bug fixes and added callback functionality

 

Example Code for All

Thanks Chris!!! 

 

<script type='text/javascript'>

var osContainer;

var dataReqObj;

var param;

 

function init(optResponse) {

      osContainer = opensocial.Container.get();

      param = {};

}

 

function getIndicator(stuff){

      if (typeof(stuff) === 'undefined'){

            dataReqObj = osContainer.newDataRequest();

            dataReqObj.add(MyOpenSpace.DataRequest.newFetchIndicatorsRequest(opensocial.DataRequest.PersonId.VIEWER, param));

      dataReqObj.send(getIndicator);

      } else {

            var result = stuff.get(MyOpenSpace.Group.VIEWER_INDICATORS).getData();

            dumpProps(result);

      }

}

 

function getMood(stuff) {

      if (typeof(stuff) === 'undefined'){

            dataReqObj = osContainer.newDataRequest();

            dataReqObj.add(MyOpenSpace.DataRequest.newFetchPersonMoodRequest(opensocial.DataRequest.PersonId.VIEWER, param));

      dataReqObj.send(getMood);

      } else {

            var result = stuff.get(MyOpenSpace.Group.VIEWER_MOOD).getData();

            dumpProps(result);

      }

}

 

function getStatus(stuff) {

      if (typeof(stuff) === 'undefined'){

            dataReqObj = osContainer.newDataRequest();

            dataReqObj.add(MyOpenSpace.DataRequest.newFetchPersonStatusRequest(opensocial.DataRequest.PersonId.VIEWER, param));

      dataReqObj.send(getStatus);

      } else {

            var result = stuff.get(MyOpenSpace.Group.VIEWER_STATUS).getData();

            dumpProps(result);

      }

}

 

function dumpProps(obj, parent) {

   for (var i in obj) {

      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }

      if (!confirm(msg)) { return; }

      if (typeof obj[i] == "object") {

         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }

      }

   }

}

 

function postBlogCallback(){

      var os_token = MyOpenSpace.MySpaceContainer.OSToken;

    var message = opensocial.newMessage("I am a blog post");

               

    message.setField(opensocial.Message.Field.TITLE, "About Testing");

    message.setField(opensocial.Message.Field.TYPE, MyOpenSpace.PostTo.Targets.BLOG);

               

    osContainer.postTo(os_token, message, null, ptCallback);

}

 

 

function ptCallback(someVal){

    if (someVal == MyOpenSpace.PostTo.Result.ERROR) {

      alert('callback gave error')

      }

    else if (someVal == MyOpenSpace.PostTo.Result.CANCELLED) {

      alert('user cancelled PostTo')

    }

    else if (someVal == MyOpenSpace.PostTo.Result.SUCCESS) {

      alert('WE ARE MEETING WITH GREAT SUCCESS!!!')

    }

    else {

      alert('Unrecognized response: ' + someVal)

      }               

}

 

init();

</script>

      <h1>Indicator, Mood, Status</h1>

      <hr noshade >

      <input type="button" onclick="getIndicator()" value="Show Owner Indicator" />

      <input type="button" onclick="getMood()" value="Show Owner Mood" />

      <input type="button" onclick="getStatus()" value="Show Owner Status" />      

      <div id="selectInsert"></div>

 

     

      <h1>Post To: Call Me Back</h1>

      <hr noshade >

      <button onclick="postBlogCallback()">Blog post with callback</button>

Comments

 

Ritesh Khanna said:

Call back is returning undefined for postTo on every instance

April 24, 2008 9:37 PM
 

Donny Mack (DM) said:

Zynga - i was able to replicate 'undefined' in IE too - FF worked. I'm having others try.

April 24, 2008 10:13 PM
 

Sebastian said:

Is the firefox scrolling issue addressed in this rollout? (see the initial postto blog post)

April 25, 2008 8:34 AM
 

Donny Mack (DM) said:

Ritesh, we have figured out the issue with undefined, it looks to be IE specific. We will get a fix in ASAP.

Sebastian, yes we have a stopgap fix in that rolled, we have a full fix in now that will roll out next week!

D

April 25, 2008 11:06 AM
 

Ritesh Khanna said:

dude, update us!

April 27, 2008 1:05 AM