MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

More Information on requestShareApp / App Invites

More Information on requestShareApp

This is a follow-up on Kyle’s post “quick update on ACC” with some implementation details.

http://developer.myspace.com/community/blogs/devteam/archive/2008/06/30/quick-update-on-acc.aspx

* As Kyle mentioned this feature is not yet in production, but will be soon. We wanted to get out the implementation details now so when we're ready to turn it on, you will be too.

Invoking requestShareApp

First let’s take a look at the signature:

opensocial.requestShareApp(recipients, reason, opt_callback);

·         recipients:  this is a person’s friend ID. We currently only support sending in one ID at a time

·         reason: this is the message you want sent. I’ll go over the rules for this below

·         opt_callback: a callback function

Reason

The reason is an opensocial.Message object that has the text you’d like to have displayed in the invite set as the opensocial.Message.Field.BODY (which you can also pass into the constructor).

There are a few rules for the text:

·         The text is limited to 150 characters – the character count does not include your application name or the sender and/or recipient display name. More on this below

·         You can not include any HTML markup. Adding your links to your application, recipient and sender will be done by us.

·         We have supplied three place holders you can use to add your application name, sender name and recipient name within links:

o   [sender] – this will be transformed to a hyperlink with the senders display name as the text. The link will go to their profile.

o   [app] – this will be transformed to a hyperlink with your application name as the text. The link will go to the applications profile.

o   [recipient] – this will be transformed to a hyperlink with the recipients display name as the text. The link will go to their profile.

·         You do not have to use all the placeholders. Example below.

Example Code

The code is pretty simple.

message = opensocial.newMessage("[sender] would like you to intall this really super application [app].");
opensocial.requestShareApp(recipientUserId, message, function(){
    alert('sent application invite');
    }
   );
recipientUserId to be the userId of the recipent.   

The stubs for requestShareApp are already in production so you can wire up your applications now. Since the call will fail you’ll want to hide the functionality until we turn things on.

There are two ways to check if SHARE_APP is enabled. One is to make the call to requestShareApp() and if it’s not enabled you’ll get an unsupported back. The second is to use getSupportedPostToTargets() to get a list of supported PostTo targets – this is not part of the OS spec, but because requestShareApp currently uses PostTo it’ll work.

function isPostToTargetLive(){
 var supported = osContainer.getMySpaceEnvironment().getSupportedPostToTargets();
 var isSupported = false;
 for(var i = 0; i < supported.length; i++){
  if(supported[ i ] === "SHARE_APP"){
   isSupported = true;
   break;
  }
 }
 return isSupported;
}

D

 

Comments

 

jose said:

thanks for the heads up on the spec!

since the implementation of requestShareApp uses PostTo, does that mean that the same response object thats used for PostTo's callback will get passed in requestShareApp's callback?

July 8, 2008 1:44 PM
 

ray said:

*

July 11, 2008 10:46 AM
 

Byki said:

Time for stupid questions... such as:

So shareApp will allow users to send individual share requests to individual friends... and it's up to the developers to build the supporting UI, right?

The only reason I ask is that hi5, in their implementation of shareApp, implemented a UI, so all you need in the app is a link that calls shareApp, and then the container takes it from there, showing the user's friend, allowing the user to select a set of friends, write a message and share the app.

That whole part we'll have to build ourselves, right?

thanks,

Christopher

July 15, 2008 5:40 AM
 

Flirt With Me said:

Any further news or dates about this?

July 16, 2008 7:32 AM
 

Oriol said:

I've read on the forum that JS function posted here returns true but the notifications section where users will receive the invites is not ready so invites goes nowhere.

Could someone at MySpace make getSupportedPostToTargets(); respond false until everything is ready?

This would simplify a lot the deployment of this new functionality on our apps.

Thank you in advance

July 16, 2008 8:53 AM
 

Artem said:

I'm not really sure, but this feature is already supported

["COMMENTS", "BLOG", "BULLETINS", "PROFILE", "SEND_MESSAGE", "SHARE_APP"] .  it's var supported contents. But i can't see any notifications on user home page who shall recieve this invitation.

July 22, 2008 12:37 AM
 

MySpace Developer Team said:

Today we rolled out some enhancements and UI fixes to our app invites feature: Install Callback Url We

August 7, 2008 4:38 PM
 

Jason said:

Does this work in Iframes?

October 31, 2008 2:18 PM
 

eye candy andy said:

afaik you can not directly call this from an iframe but if you implement the IFPC setup that's outlined elsewhere you can make a call to postTo() using SHARE_APP as the target.

Strangely - this only worked for us for about a day and has not worked since.

November 24, 2008 12:51 PM
 

X'Zarreth said:

"Greetings, I'm am From the United States, Looking for Sci-Fi, Anime' & Star Trek Friends in the My Space Japan Community..."

"Thank You for your Attention..."

                     "Very Cordially,"

              .......X'Zarreth T'Kon.......

December 8, 2008 8:19 PM
 

Lee said:

I have the same questions as Byki from a few months back - what's the deal here with building the UI?  Are we really expected as app developers to build an entire share UI?  The information around sharing applications is truly woeful for OS container sites....

December 16, 2008 2:22 AM
 

cui said:

I am a Chinese,Hard to understand, I hope you give me for some complete code.thanks!

December 25, 2008 5:43 AM