【问题标题】:Facebook share inside facebook showing og:title & og:image of the iframeFacebook 在 facebook 内分享,显示 iframe 的 og:title 和 og:image
【发布时间】:2014-06-19 09:29:48
【问题描述】:

我在客户网站 (yy.com) 上放置了一个 iFrame (xx.com),该 iFrame 有一个应该重定向到客户网站 (yy.com) 的 facebook 共享。问题在于 og:image & og:title 因为我将它们放在 xx.com bcz 我无法访问 yy.com。共享未显示我在 xx.com 中放置的图像和标题。有办法吗?

xx中的代码如下:

<head>
<meta property="og:url" content="yy.com" />
<meta property="og:title" content="title" />
<meta property="og:image" content="image-path" />
</head>

<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/ar_AR/all.js#xfbml=1&appId=xxapp-id";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-share-button" data-href="yy.com" data-type="button_count"></div>

yy.com中的代码如下:

<iframe width="950" height="600" frameborder="0" src="http://xx.com/path-to-file"></iframe>

【问题讨论】:

  • 让我们看看我是否做对了。您是在 yy.com 中构建 xx.com,还是反过来?无论如何,框架站点是通过共享按钮共享的。我会考虑分享对话https://www.facebook.com/dialog/feed?app_id=APP_ID&amp;link=your_link&amp;picture=some_pic&amp;name=title&amp;caption=caption&amp;description=etc&amp;redirect_uri=url_you_want 等。分享对话仍然有效。我不确定它是否会继续存在,但我喜欢它,因为通过简单的&lt;a href&gt;&lt;/a&gt;,你可以实现你想要的
  • 是的,我在 yy.com 中构建 xx.com。我需要显示分享数量的分享按钮
  • 那我的回答不会有任何帮助,对不起。

标签: facebook iframe


【解决方案1】:

我找到了一个解决方法如下:

我将分享按钮重定向到 xx.com 而不是 yy.com 将标题和图像 url 作为 URL 中的参数,然后在 xx.com 内我根据参数设置 og:title 和 og:image通过了,我将用户重定向到 yy.com

xx中的分享按钮如下​​:

<div class="fb-share-button" data-href="xx.com?share_url=yy.com&title=the_title&image=the_image" data-type="button_count"></div>

xx中重定向的代码如下:

<?php
$share_url = $_REQUEST['share_url'];
if(isset($share_url) && $share_url!=''){
$video_title = $_REQUEST['title'];
$video_image = $_REQUEST['image'];
?>  
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="<?php echo $video_title ?>" />
<meta property="og:image" content="<?php echo $video_image ?>" />   
<meta http-equiv="refresh" content="0; url=<?php echo $share_url ?>" />
</head>
<body>
</body>
</html>
<?php
}
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-30
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多