【发布时间】:2013-03-05 01:18:27
【问题描述】:
我创建 facebook 分享按钮的方法是: 1。创建一个 share.php(facebook 在这个虚假网站中捕获元数据并重定向到我想要分享的实际网站)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $_GET['title'];?></title>
<meta property="og:url" content="<?php echo $_GET['url'];?>" />
<meta property="og:title" content="<?php echo $_GET['title'];?>" />
<meta property="og:description" content="<?php echo $_GET['title'];?> "/>
<?
if (isset($_GET['leftImg']) && $_GET['leftImg'] != 'undefined') {
echo '<meta property="og:image" content="'.$_GET['leftImg'].'"/>';
}
if (isset($_GET['rightImg']) && $_GET['rightImg'] != 'undefined') {
echo '<meta property="og:image" content="'.$_GET['rightImg'].'"/>';
}
?>
</head>
<body>
<script>
window.location.href = "<?php echo $_GET['redirect'];?>";
</script>
</body>
</html>
2。 share.php 中需要的数据是从主页传过来的
window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent('http://' + window.location.hostname + '/share.php?url=http://yahoo.com&title=test&redirect=..&leftImg=......&' ),'sharer','toolbar=0,status=0,width=826px,height=536');
问题是,og:url 应该是什么?有两个链接:share.php 和我要分享的实际网站,
如果我使用 share.php?title=...&description=.. ,我仍然需要特定的 url,这很奇怪:它将是 share.php?url=share.php ?url=share.php 最终我仍然无法引用正确的分享网址
如果我使用实际网站,它无法收集任何元数据,因为我的想法是所有元数据都在 share.php 上
如何解决问题?谢谢
!!!!!!!!!!!!!!!2013 年 11 月 4 日更新:!!!!!!!!!!!!!!!
我找到了根本问题,它是由不同的图像来源引起的:
eg. http://www.tekxon.com.pk/sites/all/themes/bluemasters/images/gallery/3.jpg
这张图片是由 Facebook 在分享页面上按预期拍摄的,完美无瑕。
eg. http://54.251.107.161/source/test2/2012/05/07/0/3/A/Content/15/Pg015.png
但是,这个托管在我的服务器上的图像并没有像第一次那样显示在共享页面上,而是只有在我重新加载页面时才会显示。 * 虽然没有显示在分享页面上,但图片显示并存在于我的facebook主页的分享内容中。
为什么会这样,是防火墙设置不正确造成的吗?谢谢
【问题讨论】:
-
你有运行的例子吗?
-
感谢您的帮助,请查看更新后的问题
-
好的,我去看看。
-
嗯,很有趣。我以前没有听说过这样的问题……我可以看一个 fb 分享 + 播放器的例子吗?
-
太棒了,很高兴你把它修好了!
标签: php javascript facebook facebook-opengraph