Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook - show a help dialog

Tags:

php

facebook

How can I show a typical facebook modal help dialog when the user clicks on one of the links on my Facebook app?

Thanks.

like image 471
lostInTransit Avatar asked Aug 03 '09 13:08

lostInTransit


1 Answers

If you're using an IFrame app, you can use FB.UI.PopupDialog from the JS API. The bad news is that there is zero documentation for this feature, and it isn't very easy to use. The good news is that I've already figured it out! :)

// First, define the HTML content you want in the dialog as a javascript string:
var content = '<div><h2>Help is here!</h2><div>Hint: you can eat the cookies!</div></div>';

// Then add the content to this resource dictionary thing, wrapped in a div with the id "RES_ID[your identifier here]"
FB.UI.DomResources.addResourceDict(new FB.UI.DomResDict('<div id="RES_IDhelp01">' + content + '</div>'));

// Instantiate the popup dialog and show it:
var popup = new FB.UI.PopupDialog('Help?!', FB.UI.DomResources.getResourceById('help01'), false, false);
popup.show();

Of course, these bits can be spread out through your page as required, and you can use php to generate the html content for you.

Easy, right? :D Enjoy!

like image 104
Daniel Schaffer Avatar answered Sep 20 '22 05:09

Daniel Schaffer