问题描述
我要在客户网站(yy.com)上放置一个iFrame(xx.com),该iFrame具有一个Facebook共享,应该将其重定向到客户网站(yy.com).问题出在og:image& og:title,因为我将其放置在xx.com中.bcz我无法访问yy.com.共享未显示我在xx.com中放置的图像和标题.有办法吗?
I am placing an iFrame (xx.com) at the client website (yy.com), the iFrame has a facebook share that should redirect to the client site (yy.com). The problem is with the og:image & og:title as I am placing them in xx.com bcz I have no access to yy.com. The share is not displaying the image and title I am placing in xx.com. Is there a way to do so?
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中的代码如下:
The code in yy.com is as follows:
<iframe width="950" height="600" frameborder="0" src="http://xx.com/path-to-file"></iframe>
推荐答案
我发现了以下解决方法:
I found a workaround for this as follows:
我将共享按钮重定向到xx.com而不是yy.com,URL中将标题和图像url作为参数,然后在xx.com内根据参数设置og:title和og:image通过,我将用户重定向到yy.com
I redirect the share button to xx.com instead of yy.com having the title and the image url as a parameters in the URL and then inside xx.com I set the og:title and og:image according to the parameters passed and I redirect the user to yy.com
xx中的共享按钮如下:
The share button in xx is as follows:
<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中重定向的代码如下:
The code for redirecting in xx is as follows:
<?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
}
?>
这篇关于Facebook在Facebook内部共享,显示og:title& og:iframe的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!