php 在我网站的 iframe 中显示 Facebook
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5091519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Displaying Facebook in an Iframe on my website
提问by Yahoo
I want to Display Facebook's Webpage on my site ?
我想在我的网站上显示 Facebook 的网页?
<html>
<body>
<iframe src="http://www.facebook.com/" name="iframe_a"></iframe>
</body>
</html>
This just show's me an image of Facebook but not the actual content. How can i do that ?
这只是向我展示了 Facebook 的图片,而不是实际内容。我怎样才能做到这一点 ?
I tried and used Php and then echoed the content on the screen that some how worked But In that case , I cant understand How shall i Login Into facebook. When i Login it get's redirected to the Main Site.
我尝试并使用了 Php,然后在屏幕上回显了一些如何工作的内容,但在这种情况下,我无法理解如何登录 facebook。当我登录时,它被重定向到主站点。
回答by Zimbabao
This is the code facebook embedded in its pages.
这是 facebook 嵌入在其页面中的代码。
if (top != self) { try { if (parent != top) { throw 1; }
This code checks if its embedded in iframe its blocks loading other data rather loads the the link to which you can click with an image.
这段代码检查它是否嵌入在 iframe 中,它是否阻止加载其他数据,而不是加载您可以单击图像的链接。
<script type="text/javascript">
/* <![CDATA[ */if (top != self) {
try { if (parent != top) { throw 1; }
var disallowed = ["apps.facebook.com","\/pages\/","apps.beta.facebook.com"];
href = top.location.href.toLowerCase();
for (var i = 0; i < disallowed.length; i++) {
if (href.indexOf(disallowed[i]) >= 0) { throw 1; }
}
} catch (e) {
setTimeout(
function() {var fb_cj_img = new Image();
fb_cj_img.src = "http:\/\/error.facebook.com\/common\/scribe_endpoint.php?c=si_clickHymaning&m=on\u002509&t=8183";}, 5000);
window.document.write("\u003cstyle>body * { display:none !important; }\u003c\/style>\u003ca href=\"#\" onclick=\"top.location.href=window.location.href\" style=\"display: block !important; padding: 10px\">\u003ci class=\"img sp_8dfqpl sx_d67a9a\" style=\"display:block !important\">\u003c\/i>Go to Facebook.com\u003c\/a>");
/* XRCm4Hhw */ }}/* ]]> *
</script>
回答by gsbabil
Theoretically it should be possible to do it in the following steps:
理论上应该可以通过以下步骤来完成:
- Fetch the Facebook.com's html with AJAX.
- Remove the undesired javascript what Zimbabao pointed or add new javascript that overrides undesired function.
- and then do a
document.write
to release the modified HTML for the browser to parse and render.
- 使用 AJAX 获取 Facebook.com 的 html。
- 删除 Zimbabao 指出的不需要的 javascript 或添加覆盖不需要的功能的新 javascript。
- 然后执行 a
document.write
释放修改后的 HTML 供浏览器解析和渲染。
This is the same principle how Javascript-function-overriding works with GreaseMonkey [1]. In [2, 3], you will find how functions can be overridden with Javascript.
这与 Javascript-function-overriding 与 GreaseMonkey [1] 的工作原理相同。在 [2, 3] 中,您将了解如何使用 Javascript 覆盖函数。
回答by Nans
I think that Facebook is blocking its usage within an iframe tag.
我认为 Facebook 正在阻止其在 iframe 标签中的使用。
回答by Ivan
Use Facebook API to get your wall posts, and then display them where you like. http://developers.facebook.com/
使用 Facebook API 获取您的墙贴,然后将它们显示在您喜欢的地方。 http://developers.facebook.com/
回答by felixsigl
it makes really no sense to display facebook in an iframe on your website.
在您网站的 iframe 中显示 facebook 真的没有意义。
if you want to display facebook content on your page use Facebook Badges
如果您想在您的页面上显示 Facebook 内容,请使用Facebook 徽章
回答by Andy
Iframe your facebook content like this:
iframe 你的 facebook 内容是这样的:
<iframe src="http://www.facebook.com/plugins/likebox.phpid=YOURUNIQUEID&width=158&connections=5&stream=true&header=false&height=555"
scrolling="no"
frameborder="0"
style="border:none; overflow:hidden; width:158px; height:555px;"
allowTransparency="true">
</iframe>
<div class="fb-like"
align="center"
data-href="https://www.facebook.com/YOURFBADDRESS"
data-send="true"
data-width="500"
data-show-faces="false"
data-font="verdana">
</div>
回答by Vitalicus
This question is old. Now all the posts on FB have a embed with iframe, or direct link
这个问题很老了。现在FB上的所有帖子都嵌入了iframe,或直接链接