同一页面上的两个类似Facebook的按钮,带有两个不同的缩略图



我在同一页上有两个不同的产品"Prod_A"one_answers"Prod_B",比如

www.xyz.com/index1.html

这个页面上有两张这些产品的图片和小的描述。

两种产品我都需要两个相似的按钮,两个相似按钮都应该指向它们所在的页面(www.xyz.com/index1.html),但两个按钮都应该有不同的og:图像和描述。

我已经为多个按钮找到了一些解决方案,但它们引用了不同的页面,并且没有包含图片。

谢谢!

PS:一个小的工作例子将是伟大的

编辑:@DMCS表示(见评论),这是不可能的。当我为第二个产品www.xyz.com/index2.html创建一个虚拟页面时,它会重定向到页面www.xyz.com/sindex1.html吗?在这种情况下,我会有两页纸,这样可能吗?

是的,这是可能的,您需要在主页面上创建尽可能多的类似按钮的虚拟页面。每个页面都包含您需要的所有OG标签,包括描述和图像。然后使用重定向将用户带回带有按钮的页面。

使用类似facebook的按钮工具,使用每个虚拟页面的url创建按钮。下面是一个伪页面示例:-

<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>This is a dummy page to hold the OG tags</title>
<meta property="og:title" content="This is the text the like button will show in FB when liked"/>
<meta property="og:site_name" content="the site name shown, the from name in FB"/>
<meta property="og:url" content="http://www,yoursite.com/dummp_01.html" />
<meta property="og:image" content="http://www,yoursite.com/dummyimage01.jpg" />
<meta http-equiv="refresh" content="0;url=http://www.redirect_to_url_that_has_all_the_like_buttons.com">
</head><body></body></html>

您可以在地址中添加一些变量,然后使用php进行一些切换吗?

例如

Like 1链接到:http://xyz.com/index.php?like1=true喜欢2个链接:http://xyz.com/index.php?like2=true

然后在php中的index.php页面上使用if语句。。。

<?php if (isset($_GET['like1']) { ?>
[your like 1 og tags here]
<?php } else if (isset($_GET['like2']) { ?>
[your like 2 og tags here]
<?php } ?>

注意当然,这个解决方案也适用于除php-

之外的其他语言

当我为第二个产品创建虚拟页面时www.xyz.com/index2.html,它将重定向到页面www.xyz.com/index1.html?如果是这样的话,我会有两页纸,是吗可能的

是的,这是个好主意。facebooklinter不运行任何javascript,所以它可以正确地获取og标签。当用户访问该页面时,他们将被javascript重定向,并看到包含这两个产品的页面。

最新更新