开发者

Create Facebook Dialog Popup with Link

I开发者_C百科 am trying to create a Facebook Dialog using the new improvements that were released last week.

http://developers.facebook.com/blog/post/437

What I want is to be able to have a link so when it's clicked a popup is generated, or have it show up in the page. I've tried putting it in a DIV and then showing with JQuery but it won't center on the page. I've gotten the code to work for posting to the users wall... just don't know how to either format the JS code and or create the link for the popup. Thanks in advance!


As long as you have the Facebook js on your page, it's as easy as this to create a friend invitation:

<script>
    FB.ui(
     { 
      method: 'friends.add', 
      id: fbid // assuming you set this variable previously...
     }, 
     function(param){

      // If you have FireFox + FireBug or Chrome + developer tools:
      console.log(param); // log response to javascript console

            // If they cancel params will show: 
            //    {action:false, ...}
            // and if they send the friend request it'll have:
            //    {action:true, ...}
            // and if they closed the pop-up window then:
            //    param is undefined
     }
    );
</script>

You can test this by using the javascript console app on Facebook:

http://developers.facebook.com/tools/console

Paste in the script above, including the tags, or click the "Examples" button on the bottom of the text area and find the "fb.ui — friends.add" example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜