使用 Javascript SDK 的 Facebook Canvas 应用程序
希望有人能帮助我。我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在开发者应用程序中设置了画布网址/安全网址以指向您的画布代码?
这本质上应该指向您的域,例如 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.