Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook connect displaying invite friends dialog and closing on completion
    text
    copied!<p>I'm trying to create a Facebook Connect application that displays a friend invite dialog within the page using Facebook's Javascript API (through a <a href="http://developers.facebook.com/docs/?u=facebook.jslib.FB.UI.FBMLPopupDialog" rel="nofollow noreferrer">FBMLPopupDialog</a>).</p> <p>The trouble is to display a friend invite dialog you use a <a href="http://wiki.developers.facebook.com/index.php/Fb:request-form" rel="nofollow noreferrer"></a> multi-friend form which requires an action="url" attribute that represents the URL to redirect your page to when the user completes or skips the form. The problem is that I want to just close the FBMLPopupDialog (the same behavior as if the user just hit the 'X' button on the popup dialog). The best I can do is redirect the user back to the page they were on basically a reload but they lose all AJAX/Flash application state.</p> <p>I'm wondering if any Facebook Connect developers have run into this issue and have a good way to simply display a friend invite "lightbox" dialog within their website where they don't want to "refresh" or "redirect" when the user finishes.</p> <p>The facebook connect JS API provides a <a href="http://developers.facebook.com/docs/?u=facebook.jslib.FB.Connect.inviteConnectUsers" rel="nofollow noreferrer">FB.Connect.inviteConnectUsers</a>, which provides a nice dialog but only connects existing users of your application who also have a Facebook account and haven't connected.</p> <p><a href="http://bugs.developers.facebook.com/show_bug.cgi?id=4916" rel="nofollow noreferrer">http://bugs.developers.facebook.com/show_bug.cgi?id=4916</a></p> <pre><code>function fb_inviteFriends() { //Invite users log("Inviting users..."); FB.Connect.requireSession( function() { //Connect succes var uid = FB.Facebook.apiClient.get_session().uid; log('FB CONNECT SUCCESS: ' + uid); //Invite users log("Inviting users..."); //Update server with connected account updateAccountFacebookUID(); var fbml = fb_getInviteFBML() ; var dialog = new FB.UI. FBMLPopupDialog("Weblings Invite", fbml) ; //dialog.setFBMLContent(fbml); dialog.setContentWidth(650); dialog.setContentHeight(450); dialog.show(); }, //Connect cancelled function() { //User cancelled the connect log("FB Connect cancelled:"); } ); } function fb_getInviteFBML() { var uid = FB.Facebook.apiClient.get_session().uid; var fbml = ""; fbml = '&lt;fb:fbml&gt;\n' + '&lt;fb:request-form\n'+ //Redirect back to this page ' action="'+ document.location +'"\n'+ ' method="POST"\n'+ ' invite="true"\n'+ ' type="Weblings Invite"\n' + ' content="I need your help to discover all the Weblings and save the Internet! WebWars: Weblings is a cool new game where we can collect fantastic creatures while surfing our favorite websites. Come find the missing Weblings with me!'+ //Callback the server with the appropriate Webwars Account URL ' &lt;fb:req-choice url=\''+ WebwarsFB.WebwarsAccountServer +'/SplashPage.aspx?action=ref&amp;reftype=Facebook' label=\'Check out WebWars: Weblings\' /&gt;"\n'+ '&gt;\n'+ ' &lt;fb:multi-friend-selector\n'+ ' rows="2"\n'+ ' cols="4"\n'+ ' bypass="Cancel"\n'+ ' showborder="false"\n'+ ' actiontext="Use this form to invite your friends to connect with WebWars: Weblings."/&gt;\n'+ ' &lt;/fb:request-form&gt;'+ ' &lt;/fb:fbml&gt;'; return fbml; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload