Facebook 应用程序选项卡 URL

发布于 2024-08-18 10:52:08 字数 440 浏览 4 评论 0原文

我有一个 Facebook 应用程序,可以作为选项卡添加到粉丝页面。该应用程序要求用户经过身份验证才能使用它。这可以通过在链接中使用 requirelogin=1 来完成,该链接仅对未添加该应用程序的用户可见。这部分工作正常。

但是,在用户从 requirelogin 打开的 dhtml 弹出窗口授予我的应用程序权限后,我希望重新加载该选项卡。为了做到这一点,我需要将完整的 URL 包含在链接中,如下所示:

<a href="http://www.facebook.com/pages/PAGE_NAME/PAGE_ID?v=app_APP_ID" requirelogin=1>Authorize</a>

我不知道如何获取完整的 url,或者至少如何获取 PAGE_NAME 来动态构建此 url。似乎应用程序应该能够知道它在哪里,而无需任何特殊权限。

I have a facebook application that can be added to fan pages as a tab. The application requires that users are authenticated in order to use it. This can be accomplished by using requirelogin=1 in a link which is visible only to users who have NOT added the application. This part works fine.

However, after the user has given my application permission from the dhtml pop up that requirelogin opens, I want the tab to reload. In order to do that, I need the full URL to be included in the link as follows:

<a href="http://www.facebook.com/pages/PAGE_NAME/PAGE_ID?v=app_APP_ID" requirelogin=1>Authorize</a>

I cannot figure out how to get the full url or, at least, the PAGE_NAME to build this url dynamically. Seems like the app should be able to know where it is without any special permissions.

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

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

发布评论

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

评论(4

仙女 2024-08-25 10:52:08

当您的选项卡加载时,API 会向您传递一个签名请求,其中包含things,一个 page 数组包含 idliked管理员。您可以使用它来动态提取当前正在调用您的代码的页面 ID。

When your Tab is loaded, the API passes you a Signed Request that contains, amongst other things, a page array contain id, liked & admin. You can use that to dynamically pull the page id that's currently calling your code.

江城子 2024-08-25 10:52:08

如果您有 PAGE ID 和 APP ID,则可以执行以下操作:

http://www.facebook.com/profile.php?id=PAGE_ID#v=app_APP_ID

例如:

http://www.facebook.com/profile.php?id=282955631557#v=app_278523304881

If you have the PAGE ID and APP ID, this is what you do:

http://www.facebook.com/profile.php?id=PAGE_ID#v=app_APP_ID

For example:

http://www.facebook.com/profile.php?id=282955631557#v=app_278523304881
遗弃M 2024-08-25 10:52:08

在新方案中,# 不再起作用。需要使用 来

http://www.facebook.com/profile.php?id=PAGE_ID#v=app_APP_ID

向应用程序携带参数,它必须在一个名为 'app_data' 的参数中。

http://www.facebook.com/profile.php?id=PAGE_ID#v=app_APP_ID&app_data="..."

要携带多个参数,最好的策略是将 app_data 编码为 Json。

In the new scheme, the # no long works. One needs to use

http://www.facebook.com/profile.php?id=PAGE_ID#v=app_APP_ID

To carry parameters to the app, it has to be in a parameter called 'app_data'

http://www.facebook.com/profile.php?id=PAGE_ID#v=app_APP_ID&app_data="..."

To carry multiple parameters, the best strategy is to encode app_data in Json.

爱给你人给你 2024-08-25 10:52:08

以上所有答案都不起作用(仅将您重定向到页面流)或现已弃用。最好的解决方案是使用 JS:

// called when like button, box, etc is rendered
FB.Event.subscribe("xfbml.render", function() { 

    // assigns click to that thing
    FB.Event.subscribe("edge.create", function(response) { 

        window.location.reload(); // reload frame only

    });
});

您还必须加载并初始化 facebook JS SDK。如果您不知道如何操作,请使用以下命令:

<script>
    document.onload = function(){

        (function(d){
            var js,id='facebook-jssdk';
            if(d.getElementById(id)){return;}
            js=d.createElement('script');
            js.id=id;js.async=true;js.src="//connect.facebook.net/pl_PL/all.js";
            d.getElementsByTagName('head')[0].appendChild(js);
        }(document));

        window.fbAsyncInit = function(){
            FB.init({
                appId  : <PASTE_YOUR_APP_ID_HERE>,
                status : true, // check login status
                cookie : true, // enable cookies to allow the server to access the session
                xfbml  : true  // parse XFBML
            });
            FB.Event.subscribe("xfbml.render", function() {
                FB.Event.subscribe("edge.create", function(response) {
                    window.location.reload();
                });
            });
        }
    }
</script>

All of the above answers will not work (redirect you only to page stream) or are deprecated now. The best solution thou is using JS:

// called when like button, box, etc is rendered
FB.Event.subscribe("xfbml.render", function() { 

    // assigns click to that thing
    FB.Event.subscribe("edge.create", function(response) { 

        window.location.reload(); // reload frame only

    });
});

You'll also have to load and init facebook JS SDK. If you don't know how to do it, use this:

<script>
    document.onload = function(){

        (function(d){
            var js,id='facebook-jssdk';
            if(d.getElementById(id)){return;}
            js=d.createElement('script');
            js.id=id;js.async=true;js.src="//connect.facebook.net/pl_PL/all.js";
            d.getElementsByTagName('head')[0].appendChild(js);
        }(document));

        window.fbAsyncInit = function(){
            FB.init({
                appId  : <PASTE_YOUR_APP_ID_HERE>,
                status : true, // check login status
                cookie : true, // enable cookies to allow the server to access the session
                xfbml  : true  // parse XFBML
            });
            FB.Event.subscribe("xfbml.render", function() {
                FB.Event.subscribe("edge.create", function(response) {
                    window.location.reload();
                });
            });
        }
    }
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文