MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in
Blogs from the OpenSocial JS Container Team

Introducing Post To

In a nutshell, Post To enables you to provide your application users the ability to post things to MySpace. In our initial launch we’ll be offering the following Post To targets: 

-    Posting to the viewers profile
-    Posting a bulletin
-    Posting to the viewers blog
-    Adding a comment
-    Sending a message

Each of the targets can accept different levels of text and markup. For instance, some will accept HTML while others don’t and this is sometimes controlled by the end users privacy settings. Because of this we recommend thoroughly testing your applications.

This should go without saying but, SPAM will not be tolerated!

Overview 

Post To is one of our first features that will enable you to not only help your users communicate with friends but also to start virally spreading news of your application. With just a few lines of code you can start pushing content to your users profile and friends.

Post To works by allowing you to pass a few parameters to a JavaScript function that then displays an overlay over your application (see screenshots below) . The user can then perform different actions based on the target invoked and then submit or cancel the action.

Finally, Post To is currently only available on Canvas pages.

Invoking Post To 

Below we’ll go through the basics of using Post To starting with a working out of the box code example. For information on things not covered please see the http://developer.myspace.com/community/myspace/referenceIntro.aspx   

Sample Code

 

<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("supportedTargets").options[document.getElementById("supportedTargets").selectedIndex].value;

      var subject = "subject text";

      var content = "content text";

      // 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="invoke" />

 postTo

 opensocial.Container.get().postTo(os_token, message, opt_person, opt_callback);

  • os_token: The token string, this gets passed up so we can verify who's sending the request.
  • Message:  an opensocial.Message object. The content to be posted, the message type refers to the target of the post.
  • opt_person: an opensocial.Person object. An optional opensocial.Person object, used when a recipient is required, e.g. when posting a comment, this person will get the comment.
  • opt_callback: Callback function, right now just for success/fail. - not yet implemented.

openSocial.Message

Below is the function for creating a new opensocial.Message object:

var message = opensocial.newMessage(body, opt_params);

The Post To opensocial.Message message allows for three fields:

1. opensocial.Message.Field.TYPE

A supported PostTo target type from MyOpenSpace.PostTo.Targets enum. You can check if a particular target is supported by invoking: opensocial.Container.get().getMySpaceEnvironment().getSupportedPostToTargets()
Currently supported targets:
-    MyOpenSpace.PostTo.Targets.PROFILE
-    MyOpenSpace.PostTo.Targets.SEND_MESSAGE
-    MyOpenSpace.PostTo.Targets.COMMENTS
-    MyOpenSpace.PostTo.Targets.BULLETINS
-    MyOpenSpace.PostTo.Targets.BLOG

Example:
message.setField(opensocial.Message.Field.Type, MyOpenSpace.PostTo.Targets.PROFILE);

2. opensocial.Message.Field.TITLE

A title for the post – this is not used in every target

Example:

message.setField(opensocial.Message.Field.TITLE, “Hello World”);

3. opensocial.Message.Field.BODY

The content you want to post.

Example:

message.setField(opensocial.Message.Field.BODY, “Hello World”);

Note: Body can also be passed in the constructor.

Target Screen Shots 

Below are screen shots of the various targets with links on where you can find the corresponding MySpace feature

Posting to Profile
Posting to the users profile copies functionality found here: http://profileedit.myspace.com/index.cfm?fuseaction=profile.interests

Posting to Bulletin

Posting a bulletin copies functionality found here: http://bulletins.myspace.com/index.cfm?fuseaction=bulletin.edit

Posting to Blog

Making a blog post copies functionality found here: http://blog.myspace.com/index.cfm?fuseaction=blog.create&editor=true


 

Posting a Comment

Posting a comment copies functionality found here: http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID=20599042


 

Sending a Message

Sending a message copies functionality found here:  http://messaging.myspace.com/index.cfm?fuseaction=mail.message&friendID=20599042

Sample Application

Chris has created a handy sample application for you to see Post To in action. You can install it here:  http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=364361327


Comments

 

Alberto said:

Can this work from an IFRAME app as well?

April 10, 2008 6:58 PM
 

Russ Cobbe said:

Is there a RESTful API call to coincide with this?

April 10, 2008 7:16 PM
 

Donny Mack (DM) said:

This particular functionality is only accessible through our JS Container.

April 10, 2008 7:33 PM
 

andy said:

Does Myspace plan to port this functionality to iframe based apps?

April 10, 2008 8:27 PM
 

Donny Mack (DM) said:

We are looking into ways we can implement this so iframe based apps can use PostTo - when we determine the right solution I'll let you know - should be in the next few days!

April 10, 2008 8:55 PM
 

Tim said:

Is this live now?

April 10, 2008 9:45 PM
 

Prabhakar said:

When can we expect the same be available for REST API - user agent. If it takes too longer, then the flex applications will be inferior to other apps. Help us please.

April 10, 2008 10:04 PM
 

FrozenBear said:

Yes, please provide support for iframe apps.  MySpace made External Iframe apps first-class citizens by putting the option right there on the Application Builder page, alongside HTML/Javascript and Flash.  Hi5 has support for the viral features built into their REST API.  Thanks.

April 10, 2008 10:27 PM
 

FrozenBear said:

Oops, sorry, didn't see DM's message there before I posted.  Thanks, DM.

April 10, 2008 10:30 PM
 

BaPpY said:

does this  mean my app can send email to the users(both who have and have not add the app but frnds of the user who added the app).

April 10, 2008 11:41 PM
 

Donny Mack (DM) said:

Tim: YES! :-)

Prabhakar: TBD -  I'll try to get more info. for you

BaPpY: Yes

April 10, 2008 11:49 PM
 

Quizzes said:

If you just pass an opensocial token as a parameter to iframes, we could use the postTo IFPC function.

April 11, 2008 3:01 AM
 

Sebastian said:

This works great but when will the callback be implemented?

April 11, 2008 8:49 AM
 

Sebastian said:

That is a cool looking friend picker in that example app by Chris posted in this blog.. It seems to indicate that it will be part of the Myspace api.. When will this be available? Can we use it now?

April 11, 2008 9:05 AM
 

Chris Cole said:

The friend picker is free to use.  It is an early version (0.2) and has not been tested for international support, so your MMV.  

We're working through building a standard control/widget library and how best to roll that out for all you app developers.  Very likely it will be part of an optional widget library you can include when building your app, but this has not been finalized yet.  For the time being you can view source on the canvas frame for the app and embed the script code between:

/*

============================================================================================

      BEGIN MyOpenSpace.Widgets include.

============================================================================================

*/

...

and

...

/*

============================================================================================

      END MyOpenSpace.Widgets include.

============================================================================================

*/

Follow instructions in the sample app for usage.

April 11, 2008 9:34 AM
 

Russ Cobbe said:

Would I be able to call the JS functions from my server side if I include the opensocial JS files?  If so does the JS library file need to be updated in the reference section?

April 11, 2008 9:48 AM
 

Cristian said:

I have a problem with these feature, the "pop-up" dialog, doesn't seems to be work well it's cut off on the bottom, so i can't see the accept, cancel buttons, any idea how to fix it?

April 11, 2008 10:37 AM
 

Donny Mack (DM) said:

Cristian - can you try clearing your cache and if that doesn't fix it send me a screen shot - dmack at myspace

April 11, 2008 10:47 AM
 

Cristian said:

Hi DM, i cleaned my cache and stills happens. I send you an screenshots

www.engenus.net/.../screenshot-ubuntu-ff.png

www.engenus.net/.../screenshot-winxp-ff.jpg

www.engenus.net/.../screenshot-winxp-ie.jpg

On Internet Explorer seems to be fine, i think this is beacuse ie doesn't support position: fixed;

April 11, 2008 11:25 AM
 

Donny Mack (DM) said:

Ok - thanks! We'll get this fixed! It most likely will not roll out until next week though so if you could test on IE for now that'd be great.

April 11, 2008 11:42 AM
 

mNeo said:

Hi DM,

Will this be available to home and profile pages in near future? Some applications don't need / have a canvas page.

April 12, 2008 2:43 PM
 

Donny Mack (DM) said:

Hey mNeo,

We're still investigating implementing PostTo on home/profile, but since our end users can have (n) apps installed there are a few issues we have to reconcile first, for both functionality and security.

Until we make a decision then one possible solution would be to create a canvas page and use requestNavigateTo to navigate there – invoke postTo and then navigate back to source? I know that’s not optimal, but it’s something you can do now.

If you or others have thoughts on the subject we should start a forum post to discuss. This would include other PostTo targets you'd like to see!

All that said, we do have more robust application communication channels coming down the pipe so we may just keep things simple with PostTo and keep it on Canvas.

D

April 12, 2008 9:43 PM
 

Shopit said:

Will/can we send a message to more than on recipient at a time?

April 13, 2008 9:50 AM
 

Matías said:

Hey, any chance to look at what cristian told you, is very frustrating that not being able to use something that good to promote our apps, i don't want to not allow all my firefox users to use my app. Any chance you can give us a clue on where is going to be solved?, little tip, even if we do scroll down we can't see the button you will have to reload the whole page to be able to keep navigating the site, obviously that is not acceptable for our users.. :) thanks for reading and i hope it can get solved soon!

cheers

Pabli

April 14, 2008 8:49 AM
 

Matías said:

ohhh by where i mean when...:) tnxs again!

April 14, 2008 8:49 AM
 

Jim said:

Any word on when iframe apps will support "post to"?

I'm not looking for a definitely date... more of a rough idea...

April 14, 2008 8:53 AM
 

MySpace Developer Team said:

You&#39;ve probably noticed lots of changes on MDP in the last week or so. I want to quickly highlight

April 14, 2008 11:58 AM
 

Donny Mack (DM) said:

Updates:

1. working on the fix for postto over flash - thanks for your help Luke. we're hoping to have this fix in this week with a roll to production next.

2. Working on getting the fix in for Cristian's issue with buttons hidden. We have something checked in but need to verify - we'll hopefully be able to roll this out this week but it may slip - I’ll keep you posted.

3. optional callback - we should have this checked in this week and it would roll next.

4. iframe support - stretch goal for this week. sorry guys!

April 14, 2008 4:27 PM
 

Donny Mack (DM) said:

Just so you know:

We would love to get these fixes out for you as soon as possible (this week) but because we launched PostTo late in the week and we are bound by our build/roll schedule it might not be possible. I know it’s frustrating but being developers I hope you understand that these processes are in place to protect everyone.

We're going to do the best we can to get some of our verified fixes pushed in for this week’s roll but I can't promise anything.

Please keep bug reports coming so we can get as many fixes implemented as possible for next week’s roll.

Additionally, all feature requests will be considered!

D

April 14, 2008 7:49 PM
 

Sebastian said:

2 days later: what is the status of the hidden buttons issue? This functionality is completely unusable for firefox users (As many have already complained)

April 16, 2008 12:53 PM
 

Donny Mack (DM) said:

Sebastian - I've already updated on this. See above

- because of our late in the week launch we will most likely not be able to get most bug fixes out this week. Sorry for the inconvenience.

- the issue isn’t seen on all platforms using FF – looks fine for me on XP using FF

April 16, 2008 1:16 PM
 

Sebastian said:

K, thanks.. I dont know if this helps but it looks to reproduce for me at certain screen resolutions (800 height)

April 16, 2008 1:38 PM
 

Donny Mack (DM) said:

Thanks for that extra info - We technically don't support that height, but I believe we were able to come up with a fix today that will work for you.

The fix will be in next weeks push.

Thanks!

D

April 16, 2008 5:41 PM
 

jose said:

Cool feature!

Is it possible to give devs an option to prevent the user from modifying the content in the message, such as the title or adding notes?

April 16, 2008 10:09 PM
 

MDP JavaScript Container said:

I know a few of you are using the non-MDP version of PostTo found here: www.myspace.com/posttomyspace

April 17, 2008 9:12 PM
 

Olli said:

will the application be able to send messages to users' friends who don't have the applications themselves?

April 17, 2008 10:19 PM
 

ZeroSleep said:

RE: Callback

Look forward to it's availability. I'd like to use it to simulate sending multiple invitations to each friend w/out the app installed.

April 18, 2008 5:06 PM
 

Nobel K said:

!   C:\Dokumente und Einstellungen\Holger\Eigene Dateien\My Completed Downloads\mp3player.zip: The archive is either in unknown format or damaged

!   C:\Dokumente und Einstellungen\Holger\Eigene Dateien\My Completed Downloads\mp3player.zip: The archive is corrupt

April 19, 2008 12:39 AM
 

Christopher said:

Any updates on iframe support?

Thanks!

April 19, 2008 7:43 PM
 

PersonalFx Developer said:

I'm seeing a few issues with the gadget.  It seems to have issues displaying users  with hearts and I'm assuming other such characters.

Great gadget.  Been waiting for something like this to show up.

April 19, 2008 8:37 PM
 

PersonalFx Developer said:

Just tried to post a simple app that used postTo.  Denied by the admin partially for not being able to determine if the message had been sent or not.  Seems like a callback would be handy for determing such things.  A little frustrated by the deny for something that's out of our control.

April 21, 2008 12:09 AM
 

Jason said:

Is there an ETA for iFrame support?  

April 21, 2008 6:31 PM
 

Kevin said:

Any updates on iFrame support?  This is functionality is crucial!

April 28, 2008 1:12 PM
 

CC said:

Hi,

can u check this post

developer.myspace.com/.../1966.aspx

April 28, 2008 8:37 PM
 

Russ Cobbe said:

Any update on iFRAME support?  Apps that use this are suffering and not growing because of the lack of this support.  

May 2, 2008 6:39 AM
 

BeFunky said:

Guys, any update for the iframe applications. We are out of the competition. This is not fair....

May 6, 2008 1:30 AM
 

BuboMe.com said:

That is exactly right, please, when is this going to be released for Iframe apps?

May 9, 2008 3:10 AM
 

Abhishek Jain said:

hi how to post flash object (widget) from  a web application to MySpace profile

May 9, 2008 4:35 AM
 

shashi said:

any updates for iframe ?

May 13, 2008 2:38 AM
 

Clint said:

Hi guys,

Any updates on IFRAME support?  Bump

May 17, 2008 9:16 AM
 

Test said:

Any Iframe news :S??

Mat

May 20, 2008 11:46 AM
 

Marvin said:

It only seems sensible to allow use of the PostTo MySpace for apps that use IFrames.

June 9, 2008 6:19 AM
 

Are you worthy said:

Also wondering about the iframe support....

July 12, 2008 6:44 PM
 

Barbara Kim said:

Testing...1,2...

August 24, 2008 2:08 AM
 

Rohan said:

How can we simulate opensocial.Person object using REST? any ideas??

( we just need 2 parameters the image,name )

if we propogate opensocial_token and then do ifpc call it works but i don't get the photo & name but it does send it to the right person.

August 27, 2008 9:35 PM
 

hui said:

here are the params for the postto call for the ifpc:

postto(os_token, post_type, subject, content, opt_recipientId, opt_recipientImage, opt_recipientName, opt_recipientProfile, opt_callback);

personally i haven't test out the callback yet. but at least the name, image, and profile link works.

August 28, 2008 2:37 PM
 

kalle said:

This is not working, right? can anyone please point in the right direction for sending some sort of message/add request/notification from AS3?

August 29, 2008 1:23 AM
 

Rohan said:

postto(os_token, post_type, subject, content, opt_recipientId, opt_recipientImage, opt_recipientName, opt_recipientProfile, opt_callback);

is the opt_callback working??

How do i send it to multiple people..??

Thanks in advance.

September 4, 2008 7:22 AM
 

Kirkland said:

Does anyone know what is needed for the Post To work with iframe apps?

Do i need to add code to .fla file? please advise what is needed.

September 10, 2008 7:36 PM
 

Daniel said:

I have a user ID how can I create a recipientPerson object from it?

I need it to invoke postTo method

October 25, 2008 4:24 AM
 

Carol said:

Wake up and stop all this spying and controling of other users innocent use on websites.  Where is my man with the real almighty technology power to stop all these programs that invade privacy.    these people do not deserve the privelge of getting their nutshells off on hidden codes and feeling pleasure from sinful actions website users have on their computers.  Praying their will be changes according to God's word.  Or is this just a money making sinful computers and programs full of evil unable to fight satan do to their weak mind.  Your choice you know right from wrong!!!!!!!!

November 18, 2008 3:04 AM
 

James Gillmore said:

Does the new Iframe library support ALL post to functions mentioned here?

This is the library I'm referring to:

developer.myspace.com/.../33442.aspx

January 18, 2009 11:15 PM
 

James Gillmore said:

Oh, and please remove that crazy christian evangelist's comment from this extremely useful article. Doesn't shee look crazy in that weird outfit!

January 18, 2009 11:15 PM
 

Aaron said:

Can I use this functionality to prefill the subject line of a message?

I was expecting to be able to do the following.

messaging.myspace.com/index.cfm

I know this is not using postTo.

March 3, 2009 11:00 AM