使用 Javascript SDK 的 Facebook Canvas 应用程序

发布于 2024-12-07 14:19:22 字数 2063 浏览 1 评论 0原文

希望有人能帮助我。我有一个 Facebook 画布应用程序。我使用此代码来验证

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

        this.vars = {
            access_token: '',
            album_id: '',
            items: '',
            user_id: '',
            photo_path: '',
            errorHandler: 'There was a problem posting your picture!<br> Please contact <a href="mailto:[email protected]">[email protected]</a>',
            counter: 1
        }

    authenticate();

    function authenticate() {

        FB.getLoginStatus(function(response) {
            if(response.authResponse) {
                // logged and known to app
                // store access token
                vars.access_token = response.authResponse.accessToken;
                sendUserInformation();
            } else {
                // not logged in or unknow to app
                // prompt user to authorize app
                FB.login(function(response) {
                    if(response.authResponse) {
                        // store access token
                        vars.access_token = response.authResponse.accessToken
                        sendUserInformation();
                    }
                }, {scope: 'email,read_stream,user_birthday,user_photos,publish_stream'});          
            }
        });
    } 

};
(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol
        + '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());

我的问题是,运行此代码不会在 facebook iframe 中显示我的页面。它只保留在网络域中。我需要的是让这个页面显示在 facebook iframe 中。

我需要添加什么才能实现这一点?

任何帮助表示赞赏!

Hope someone can help me out. I have a facebook canvas application. I'm using this code to authenticate

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

        this.vars = {
            access_token: '',
            album_id: '',
            items: '',
            user_id: '',
            photo_path: '',
            errorHandler: 'There was a problem posting your picture!<br> Please contact <a href="mailto:[email protected]">[email protected]</a>',
            counter: 1
        }

    authenticate();

    function authenticate() {

        FB.getLoginStatus(function(response) {
            if(response.authResponse) {
                // logged and known to app
                // store access token
                vars.access_token = response.authResponse.accessToken;
                sendUserInformation();
            } else {
                // not logged in or unknow to app
                // prompt user to authorize app
                FB.login(function(response) {
                    if(response.authResponse) {
                        // store access token
                        vars.access_token = response.authResponse.accessToken
                        sendUserInformation();
                    }
                }, {scope: 'email,read_stream,user_birthday,user_photos,publish_stream'});          
            }
        });
    } 

};
(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol
        + '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());

My problem is, running this code doesn't show my page in a facebook iframe. it just stays on the web domain. What I need is to get this page shown in a facebook iframe.

What do I have to add to make this happen?

Any help is appreciated!

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

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

发布评论

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

评论(1

娇纵 2024-12-14 14:19:22

您是否在开发者应用程序中设置了画布网址/安全网址以指向您的画布代码?

这本质上应该指向您的域,例如 http://mydomain.com/mycanvasfolder,其中画布文件夹将具有索引您想要显示的页面。

您应该能够看到一个基本页面,没有任何其他配置或 FB 内容。

Have you set your canvas url/secure url in the developer app to point to your canvas code?

This should essentially point to your domain like http://mydomain.com/mycanvasfolder where the canvas folder would have the index page you want to show.

You should be able to see a basic page without any other configuration or FB stuff.

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