Facebook 炸毁了我的网页
我有一个网站,集成了粉丝盒和 Facebook 的其他一些东西。为了让一切看起来正确,我实现了 FBML,如下所示:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">
它实际上工作得很好,只是我发现我客户的公司对员工设置了阻止,因此他们无法访问 Facebook。然而,这会导致该网站崩溃并且无法完全加载,因为防火墙不允许该网站上的 FB 代码正确触发。
由于我没有这个块,我在远程复制它时遇到了麻烦,并且无法准确指出它正在做什么导致它显示不正确。
简而言之,我可以在代码中实现一些东西来检查并查看 FB 是否可访问,并且仅在可访问时才触发 fbml?我主要使用 PHP 和 Jquery 来创建该网站。
提前致谢。
编辑:按要求编写代码片段
从头开始:
<!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" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">
然后在调用 fanbox 的页面中:
<div id="fbbox">
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<div id="fb-root">
<fb:fan profile_id="xxxxxxxx" width="235" height="200" connections="12" stream="false" header="false" css="http://www.xxxx.com/xxxx.css?33" ></fb:fan>
</div>
<script>
<!--
window.fbAsyncInit = function() {
FB.init({appId: 'xxxxxxx', status: true, cookie: false, xfbml: true});
};
(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);
}());
-->
</script>
</div>
我已经删除了一些特定设置,但我可以向您保证这些在实际代码中是正确的。
I have a website that integrates a fan box and a few other things from facebook. to get everything to look right, i've implemented FBML as follows:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">
it does actually work just fine, except I've found that my client's company has a block in place on employees so they can't access Facebook. This however is causing the site to blow up and not load completely as the firewall won't allow the FB code on this site to fire correctly.
As I don't have this block in place, i'm having trouble replicating it remotely and haven't been able to pin point exactly what it's doing that's causing it to display incorrectly.
In short, is there something I can implement in the code to check and see if FB is accessible and only fire the fbml if it is? I'm using PHP and Jquery primarily for the site.
Thanks in advance.
edit: Code snippets as requested
From the beginning:
<!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" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">
Then within the page calling a fanbox:
<div id="fbbox">
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<div id="fb-root">
<fb:fan profile_id="xxxxxxxx" width="235" height="200" connections="12" stream="false" header="false" css="http://www.xxxx.com/xxxx.css?33" ></fb:fan>
</div>
<script>
<!--
window.fbAsyncInit = function() {
FB.init({appId: 'xxxxxxx', status: true, cookie: false, xfbml: true});
};
(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);
}());
-->
</script>
</div>
I have xxx'ed out some of the specific settings, but I can assure you these are correct in the actual code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 facebook.com 对用户被阻止,社交插件将无法加载 anf,因此不会在您的网站上呈现。您应该检查插件是否加载,以及它们是否不会将内容替换为允许您的网站在没有它们的情况下继续运行的内容。
If facebook.com is blocked for the user, the social plug-ins canot load anf therefore will not render on your site. You should check to see if the plug-ins load and if they do not replace the content with something that allows your site to continue to function without them.
取决于网站被阻止的方式。
你可以从 facebook 加载一个小图像,然后检查 javascript 中的尺寸。所以你看看它们是否正确。
为此,我建议使用从 api 文档获取的个人资料图片的永久 url,因为它不会更改,并且始终提供相同大小的图像(根据文档)。
例如:http://graph.facebook.com/joseph.hopfgartner/picture
你可以还可以使用 facebook 跨站点脚本接收器。
另一种可能性是在 iframe 中加载来自 facebook 的内容。 location 属性将(作为唯一的属性)被您的站点读取。您可以使用将被重定向的 url(例如个人资料图片 url)。
然而这是为了回答你的问题,但我认为这不是一个解决方案。如果某些资源被阻止,您的网站确实不应该“无法加载”!
你的 html 属性不会导致这种情况,所以你搞乱了其他东西,
你可以提供更多代码或关于你的实现的链接吗?
depends on how the site is blocked.
you could just load a small image from facebook, and then check the dimensions in javascript. so you see if they turn out to be correct.
for that i would suggest using the permanent url of your profile picture you get from the api docs, as it wont change and always delivers an image of the same size (according to the docs).
ex: http://graph.facebook.com/joseph.hopfgartner/picture
you could also play with the facebook cross-site-script reciever.
another possibility is to load something from facebook in an iframe. the location property will (as the only property) be readable by your site. you could use an url that will be redirect (as for example the profile picture url).
however this was to answer your question, but i think its not a solution. your site should really not "not load" if some resources are blocked!
your html attributes can't cause that so you messed something else up
could you provide more code or a link on your implementation?