0

I have a facebook application that is a tab inside a fan page.

I have used the signed request to see if a user likes the page and show content based on that.

I have also managed to use get the facebook user id after prompting the user to log in and grant access to the application.

What I CAN'T do, is get the 'apprequests' functionality to work. I have tried it a couple of ways:

FYI - am using this version of jquery: https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

    <div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<form id="form1" runat="server">

<script type="text/javascript">

    window.fbAsyncInit = function() {
        FB.init({ appId: 'myappid', xfbml: true, cookie: true, oauth: true });
    };

    function inviteFriends() {
        FB.ui({
            method: 'apprequests',
            message: 'Enter this cool competition http://www.facebook.com/pages/My-Test-Fan-Page/204123762998981?sk=app_308637695832192',
            redirect_uri: 'http://www.facebook.com/pages/My-Test-Fan-Page/204123762998981?sk=app_308637695832192',
            display: 'iframe'
        },
            function (response) {
                console.log(response);
            }
        );
    }

....

when I do this, there are 2 issues (and I think they're probably related) 1. The request isn't sent to the selected users 2. The function for the response isn't called. When I call the FB.ui method, I can selected users, but when I do that, the dialog shows a loading screen and just shuts down.

One thing that I found strange was that when I didn't include the 'redirect_uri' parameter (which from what I can see should not be necessary), I got an error saying the application did not own the call back url.

I have also tried doing it this way

    var message = 'Enter this cool competition';
                var requestUrl = 'http://www.facebook.com/dialog/apprequests?app_id=308637695832192&redirect_uri=http://localhost:51934/Default.aspx&message=' + message;
                window.top.location.href = requestUrl;

This also appears to work, I can select users and it appears to work - I get the users that I added in the to[0], to[1], etc query string paramaeters.

Is there anything I'm doing that's wrong and could be causing this? When I request the user to authorize the app, I'm just requesting standard access, as far as I can tell from the Facebook docs this is all that should be required. I'm also wandering if there's some limitations on what can be done inside a page ta?

Any help would be greatly appreciated.

4

1 回答 1

2

我也一直在为这个问题苦苦挣扎,并认为我可能有一个可能的解决方案供您尝试。

对于数字 1)在应用程序设置中,我只设置了页面选项卡选项的 url,当我选择将应用程序作为 facebook 应用程序时,突然请求被传递并显示。

对于数字 2)我设置了 redirect_uri 并且没有调用回调函数,对话框将关闭。我认为 redirect_uri 仅在显示弹出时才会执行。尝试删除 redirect_uri 选项和 display 选项

顺便说一句,我也收到了关于不拥有重定向 uri 的错误。我不确定我改变了什么,这意味着我停止获取它,但怀疑是当我将 sdk init html 移动到 body 标记之后,如此处所述https://developers.facebook.com/docs/reference/ javascript/我之前在body标签关闭之前就有过它。希望这可以帮助。

于 2011-11-25T01:05:59.190 回答