MySpace Developer Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

PostTo error

Last post 06-20-2008 1:38 AM by Marvin. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-09-2008 4:18 AM

    PostTo error

     I am using Post To, to create a bulletin button but i keep getting the error "MyOpenSpace is not defined".  I am using the code below. 

    <script type='text/javascript'>
     
    var os_token = MyOpenSpace.MySpaceContainer.OSToken;
    var osContainer = opensocial.Container.get();

    // gets all supported post to targets
    var supported = osContainer.getMySpaceEnvironment().getSupportedPostToTargets();
    var recipientPerson;

    // need a person object for add comment and send message

    function init() {

        dataReqObj = osContainer.newDataRequest();

        dataReqObj.add(osContainer.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER));

        dataReqObj.send(ownerResponse);

    }

     

    function ownerResponse(data) {

        recipientPerson = data.get(opensocial.DataRequest.PersonId.OWNER).getData();

          loadSupportedTargets();

    }

     

        

    function loadSupportedTargets() {

          var temp = "<select id=\"supportedTargets\">";

          for (var i = 0; i < supported.length; i++)

          {

                temp += "<option value=\"" + supported[ i ] + "\">" + supported[ i ] + "</option>";

          }

          temp += "</select>";

          document.getElementById("selectInsert").innerHTML = temp;

    }

     

    function invokePostTo(){

          var target_is_supported = false;

          var target = document.getElementById(MyOpenSpace.PostTo.Targets.BULLETINS).options[document.getElementById(MyOpenSpace.PostTo.Targets.BULLETINS).selectedIndex].value;

          var subject = "jhgjhgjhgjh";

          var content = "uiuygujhgjhgg";

          // make sure that the selected target is enabled

          for (var i = 0; i < supported.length; i++) {

                if (supported[ i ] === target) {

                      target_is_supported = true;

                      break;

                }

          }

        

          if (target_is_supported) {

                // create a new message object passing in the content to be posted and then set the subject and target fields

                var message = opensocial.newMessage(content);

                message.setField(opensocial.Message.Field.TITLE, subject);

                message.setField(opensocial.Message.Field.TYPE, target);

                // show post to

                osContainer.postTo(os_token, message, recipientPerson);

          }

    }

     

    init();

    </script>

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

    <br>

    <input type="button" onclick="invokePostTo()" value="Invite Friends" />

     

    Please help! 

  • 05-13-2008 4:06 PM In reply to

    • Randy
    • Not Ranked
    • Joined on 05-07-2008
    • Posts 5

    Re: MyOpenSpace is not defined error

    Make sure you are only using this code on the 'Canvas Page'

    PostTo is currently only available on Canvas pages.

    Hope that helps...

    -Randy 

  • 05-14-2008 4:52 AM In reply to

    Re: MyOpenSpace is not defined error

    It's on the canvas page. Are there any calls that i should include prior to my code?

     

    Marvin 

  • 06-05-2008 7:08 AM In reply to

    • Tweeka
    • Not Ranked
    • Joined on 03-07-2008
    • Posts 1

    Re: MyOpenSpace is not defined error

    BUMP!

    Any MDP Team people help with this? Getting this error and not sure why too....

    Filed under: ,
  • 06-20-2008 1:38 AM In reply to

    Re: MyOpenSpace is not defined error

     Solved. You can go ahead and delete this forum.

Page 1 of 1 (5 items)