在Facebook应用程序中的对话框中邀请朋友 [英] invite friends in a dialog in a Facebook application

查看:126
本文介绍了在Facebook应用程序中的对话框中邀请朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个Facebook应用程序,使用Facebook的Javascript API(FB.ui)在应用程序中显示一个朋友邀请对话框。

I'm trying to create a Facebook application that displays a friend invite dialog within the application using Facebook's Javascript API (FB.ui).

为了做到这一点遵循本教程

我有两个问题:


  1. 我在请求中放置的动作网址 - 表单为 http://apps.facebook.com/appname/post_invite.php
    ,但我发现帖子后的iframe来源是 http://example.com/post_invite .php
    ,当这个iframe尝试做:
    parent.closeInviteWidget();
    我得到一个错误说:

  1. The action url I've put in the request-form is "http://apps.facebook.com/appname/post_invite.php" but I see that the iframe source after the post is "http://example.com/post_invite.php" and when this iframe tries to do: parent.closeInviteWidget(); I get an error saying:


拒绝 http://example.com >(document.domain尚未设置)从< http://apps.facebook.com >(document.domain =< http://facebook.com >)。

"Permission denied for < http://example.com > (document.domain has not been set) to get property Window.closeInviteWidget from < http://apps.facebook.com> (document.domain=< http://facebook.com>)."


  • 请求单中的跳过按钮会在新窗口(新的浏览器标签)中打开动作网址,自己就像邀请按钮一样。

  • The skip button inside the request-form opens the action url in a new window (new browser tab) and not post to itself like the invite button.

    如何解决这些问题?

    --------------------更新:---------------------- ----------

    -------------------- UPDATE : --------------------------------

    如果你说过,我已经尝试做了,并将代码更改为:

    I've tried to do what ifaour said and changed the code to:

    function inviteFriends(user_name, category_id, category_name)
    {
        url = appBaseUrl + "/index.php?category_id=" + category_id;
        req = "<fb:req-choice url='" + url + "' label='Authorize My Application' />";
        content = user_name + " opened a new category called " + category_name + ". " + req;
        action = 'post_invite.php';
    
        fbmi_text = '<fb:request-form action="' + action + '" target="_self" method="post" invite="true" type="Invite" content="' + content + '" <fb:multi-friend-selector showborder="false" actiontext="Invite yor friends" email_invite="false" import_external_friends="false" /> </fb:request-form>';
    
        FB.ui({
        method:'fbml.dialog',
        width:'750px',
        fbml:fbmi_text
         });
    }
    

    当我使用FireBug并查看邀请表单时,它看起来像这样: / p>

    When I use FireBug and look at the invite form it looks like this:

    <form id="req_form_4d20682f73ddb6e71722794" content="I've opened a new category called dsfsd. <fb:req-choice url='http://apps.facebook.com/appname/index.php?category_id=60' label='Authorize My Application' /> type="Invite" invite="true" method="post" target="_self" action="http://apps.facebook.com/appname/post_invite.php">
    ...
    </form>
    

    但我仍然收到相同的错误:

    But I still get the same error:


    http://example.com (document.domain尚未设置)的权限被拒绝以获取属性Window.closeInviteWidget从 http://apps.facebook.com (document.domain = http://facebook.com )...

    Permission denied for http://example.com (document.domain has not been set) to get property Window.closeInviteWidget from http://apps.facebook.com (document.domain=http://facebook.com)...

    这是我的应用设置(我添加了空格,因为我不能添加更多链接):

    站点URL: http://appname.example.com/

    画布页面: http://apps.facebook.com/appname/

    画布网址: http://appname.example.com/

    画布FBML / iframe:iframe

    发布 - 授权重定向网址: http://apps.facebook.com/appname/

    This are my app settings (I've added spaces because I can't add more links):
    Site URL : http://appname.example.com/
    Canvas Page : http://apps.facebook.com/appname/
    Canvas URL : http://appname.example.com/
    Canvas FBML/iframe : iframe
    Post-Authorize Redirect URL : http://apps.facebook.com/appname/

    推荐答案

    请阅读官方Facebook 文档

    Please have a read of the official Facebook document.

    还要尝试使用 action =http://appname.mydomain.com/post_invite.php

    编辑:我刚刚意识到!您是否使用IFrame或FBML作为画布类型?!

    如果您使用IFrame,则 fb:serverFbml

    I've just realized! are you using IFrame or FBML as canvas type?!
    If you are using IFrame then fb:serverFbml is needed to use FBML within your IFrame.

    另请注意,FBML将已弃用

    Also please note that FBML will be deprecated:


    我们正在弃用
    FBML。如果您正在Facebook.com上建立一个新的
    应用程序,那么
    将使用HTML,
    JavaScript和CSS实现您的应用程序。您可以使用
    JavaScript SDK和社交插件
    嵌入许多与FBML相同的社交
    功能。虽然
    仍然有功能,我们
    还没有移植,我们没有
    更长的添加新的功能到FBML。

    We are in the process of deprecating FBML. If you are building a new application on Facebook.com, please implement your application using HTML, JavaScript and CSS. You can use our JavaScript SDK and Social Plugins to embedded many of the same social features available in FBML. While there is still functionality that we have not ported over yet, we are no longer adding new features to FBML.

    这篇关于在Facebook应用程序中的对话框中邀请朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆