requestShareApp
With this function it's possible to send an invite for sharing a gadget with friends.
The official API reference can be found here: http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.html#requestShareApp
Restrictions on our implementation
- We have adjusted this call to a dialogbox which is called and the window has to be granted by the viewer. The default reason of the invite is: "_displayname_ invites you to _gadget_title_".
- When the dialog is closed without sending any invites (e.g. by pressing the X button), the callback function is also called, but the list of recipients will be an empty array.
- Reason is not passed through
- The "recipients" is only used to preselect up to 10 recipients. You get a selectbox with all your friends.
- When testing this function within the Sandbox it's only possible to send application invites from API-partner to API-partner. Invites that are addressed to non API-partner Hyvers are not send.
Example of how to use requestShareApp
<?xml version="1.0" encoding="UTF-8"?> <Module> <ModulePrefs title="RequestShareApp" summary="" description="" author="" author_email="" thumbnail="" screenshot="" height="380"> <Require feature="opensocial-0.7"/> <Require feature="views"/> </ModulePrefs> <Content type="html"> <![CDATA[ <script type="text/javascript"> var shareApp = function() { opensocial.requestShareApp([], 'This reason sentence is not used at the moment', requestShareAppCallback); } var requestShareAppCallback = function(responseItem) { // list of users that received the invite if(responseItem.hadError()) { var sErrorcode = responseItem.getErrorCode(); alert(sErrorcode); } else { var aData = responseItem.getData(); if(aData.length != 0) { for (i=0;i<aData.length;i++) { alert(aData[i]); } } else { // No application invite send } } } var getViewer = function() { if(opensocial.hasPermission(opensocial.Permission.VIEWER)) { shareApp(); } else { alert('no viewer permission'); } } var isViewer = function() { opensocial.requestPermission([opensocial.Permission.VIEWER], 'This reason sentence is not used at the moment', getViewer); } </script> <input type="button" value="Call invite-box" onClick="isViewer();"> ]]> </Content> </Module>
Example install: http://gorillaapi.hyves.fm/gapmember/13682719/RequestShareApp/yaKFr69q/
Example file: http://www.apikooien.nl/examples/opensocial/application_invite.xml
