serverfbml 在一页上返回 404,而不是克隆
这个案子看起来令人难以置信。
我有两个版本的 fbml 页面来显示要邀请的用户列表。两个页面返回相同的 html。唯一的区别是,一个有一个类似于 http://mydomain/user/myFriends 的 url,另一个有一个 url http://mydomain/facebook/myFriends。
一个版本运行良好,而另一个版本则在浏览器尝试从 facebook 获取 serverfbml 时卡住返回 404。这是在 IE 和 Firefox 中尝试的。
更奇怪的是,如果我使用 firefox firebug 调试器并单击获取 serverfbml 的 url 并要求它在单独的选项卡中加载它,我仍然会得到相同的行为。但我可以查看 Firefox 加载的两个页面的源代码,发现它是不一致的。
这是该页面的 html。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link type="text/css" rel="stylesheet" href="/css/common.css"/>
</head>
<body id="page-facebook" class="facebook page-facebook-showInviteFriends logged-in ">
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<fb:serverFbml width="760" height="346" style="width: 760px; height: 346px;">
<script type="text/fbml">
<fb:fbml style="width: 324px; height: 346px;">
<fb:request-form
action=""
method="POST"
invite="true"
type="Sample Name"
content="<fb:req-choice url='' label='Join Now!'></fb:req-choice>
">
<fb:multi-friend-selector
condensed="true"
showborder="true"
actiontext="Invite your friends"
email_invite=false
import_external_friends=false
exclude_ids=""
unselected_rows="10"
selected_rows="3"
/>
<fb:request-form-submit import_external_friends="false" label="null" />
</fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>
</html>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '130456257111111',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://sample.foobar.com/static/html/channel.html'
});
};
(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/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<script type="text/javascript" src="/js/facebook.js"></script>
</body>
</html>
This case seems unbelievable.
I have two versions of a fbml page to display a list of users to invite. The two pages return identical html. The only difference is that one has a url like http://mydomain/user/myFriends and the other has a url http://mydomain/facebook/myFriends.
One version works great and the other gets stuck returning a 404 when the browser tries to get serverfbml from facebook. This is try in both IE and Firefox.
What's even weirder is that if I use the firefox firebug debugger and click on the url for the get for serverfbml and ask it to load it in a separate tab, I still get the same exact behavior. But I can look at the source loaded by firefox for both pages and see that it is INDENTICAL.
Here's the page's html.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link type="text/css" rel="stylesheet" href="/css/common.css"/>
</head>
<body id="page-facebook" class="facebook page-facebook-showInviteFriends logged-in ">
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<fb:serverFbml width="760" height="346" style="width: 760px; height: 346px;">
<script type="text/fbml">
<fb:fbml style="width: 324px; height: 346px;">
<fb:request-form
action=""
method="POST"
invite="true"
type="Sample Name"
content="<fb:req-choice url='' label='Join Now!'></fb:req-choice>
">
<fb:multi-friend-selector
condensed="true"
showborder="true"
actiontext="Invite your friends"
email_invite=false
import_external_friends=false
exclude_ids=""
unselected_rows="10"
selected_rows="3"
/>
<fb:request-form-submit import_external_friends="false" label="null" />
</fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>
</html>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '130456257111111',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://sample.foobar.com/static/html/channel.html'
});
};
(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/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<script type="text/javascript" src="/js/facebook.js"></script>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了问题所在。该应用程序注册到 mydomain/facebook 的画布页面。因为其他页面的 url 不在 /facebook 下,所以调用失败。这是 Facebook 发出的非常糟糕的错误消息。文档中没有任何明显的地方明确要求获取的所有内容必须位于画布 url 模式下。
因此,我通过将官方画布 url 更改为根路径并更改默认 url 映射到我的应用程序的方式来修复此问题。
I figured out the problem. The app is registered with a canvas page of mydomain/facebook. Because the other page has a url that is not under /facebook the call fails. This is really poor error messages from Facebook. Nowhere obvious in the doc does it make it clear that it is a requirement that all content fetched must be under the canvas url pattern.
So I fixed it by changing my official canvas url to be a root path and changing how the default url gets mapped to my app.