Facebook 应用程序请求

发布于 2024-12-18 02:28:00 字数 1927 浏览 0 评论 0原文

我有一个 Facebook 应用程序,它是粉丝页面内的一个选项卡。

我已使用签名的请求来查看用户是否喜欢该页面并根据该页面显示内容。

我还设法在提示用户登录并授予对应用程序的访问权限后使用获取 facebook 用户 ID。

我不能做的是让“apprequests”功能正常工作。我尝试了几种方法:

仅供参考 - 我正在使用此版本的 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);
            }
        );
    }

....

当我这样做时,有两个问题(而且我思考他们可能是相关的) 1. 请求未发送给选定的用户 2. 未调用响应函数。 当我调用 FB.ui 方法时,我可以选择用户,但是当我这样做时,对话框会显示加载屏幕并关闭。

我发现奇怪的一件事是,当我没有包含“redirect_uri”参数(从我看来应该没有必要)时,我收到一条错误消息,指出应用程序不拥有回调 URL。

我也尝试过这样做

    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;

这似乎也有效,我可以选择用户并且它似乎有效 - 我得到了我在 to[0]、to[1] 等查询字符串参数中添加的用户。

我做的任何事情是错误的并且可能导致这种情况吗?当我请求用户授权该应用程序时,我只是请求标准访问权限,据我从 Facebook 文档得知,这就是所需要的全部内容。我还想知道页面内可以做什么是否有一些限制?

任何帮助将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小巷里的女流氓 2024-12-25 02:28:00

我也为这个问题苦苦思索了一整夜,我想我可能有一个可能的解决方案供你尝试。

对于第 1 点)在应用程序设置中,我只设置了“页面选项卡”选项的 url,当我选择同时将该应用程序作为 Facebook 应用程序时,请求突然被传递并全部显示。

对于第二个)我设置了redirect_uri并且回调函数没有被调用,对话框将关闭。我认为redirect_uri仅在弹出显示时才起作用。尝试删除redirect_uri选项和显示选项

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

I have been wrestling all night with this issue too and think I may have a possible solution for you to try.

For number 1) In the app settings I had only set the urls for the Page Tab option, when I selected to ALSO have the app as a facebook app suddenly the requests were delivered and all showing.

For number 2) I had redirect_uri set and the call back function was not being called, the dialog would just close. I think redirect_uri is only actioned when the display is popup. Try removing the redirect_uri option and the display option

By the way, I was also getting that error regarding not owning the redirect uri. I don't know for sure what I changed that meant I stopped getting it but suspect it was when I moved the sdk init html to just after the body tag as described here https://developers.facebook.com/docs/reference/javascript/ I had previously had it just before the close of the body tag. Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文