我正在运行 vBulletin 4.1.5 并且我已经配置了它的 Facebook 设置。我面临的问题是当有人点击 LIKE 按钮时,在 Facebook 上发布的缩略图不是线程中的第一个图像,它会从页面的任何地方随机选择,即在该线程中回复的任何用户的头像!
感谢你的帮助!
我正在运行 vBulletin 4.1.5 并且我已经配置了它的 Facebook 设置。我面临的问题是当有人点击 LIKE 按钮时,在 Facebook 上发布的缩略图不是线程中的第一个图像,它会从页面的任何地方随机选择,即在该线程中回复的任何用户的头像!
感谢你的帮助!
一种解决方案是您可以为所有共享定义一个全局“facebook-thumbnail”。
去
此图像应该是您的站点徽标或其他内容。
我仍在使用 vB3.8.x 进行编程,但是我正在开发一个喜欢 facebook 的插件。可能会帮助您编写自己的 vB4.x
首先,您需要定义 opengraph 和 facebook 命名空间:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
<head profile="http://gmpg.org/xfn/11">
其次,你需要facebook的javascript:
<scr ipt type="text/javascript" src="http://connect.facebook.net/en_US/all.js#xfbml=1">
</scr ipt>
最后,您需要在 html 页面部分中定义的打开图形标签:
<meta property="og:type" content="article" />
<meta property="og:title" content="this shows up as article's title when you like" />
<link rel="image_src" href="http://www.yoursite.com/yoursite1.jpg" />
<meta property="og:image" content="http://www.yoursite.com/yoursite1.jpg" />
<link rel="image_src" href="http://www.yoursite.com/yoursite2.jpg" />
<meta property="og:image" content="http://www.yoursite.com/yoursite2.jpg" />
<link rel="image_src" href="http://www.yoursite.com/yoursite3.jpg" />
<meta property="og:image" content="http://www.yoursite.com/yoursite3.jpg" />
<link rel="image_src" href="http://www.yoursite.com/yoursite4.jpg" />
<meta property="og:image" content="http://www.yoursite.com/yoursite4.jpg" />
我正在开发的插件将遍历帖子的前 5 个附件并写出 image_src 标签和 og:image 标签。还不确定我会使用哪个钩子。
伪代码:
$attachs = $db->query_read_slave("
SELECT attachmentid, attachment.dateline
FROM " . TABLE_PREFIX . "post AS post
INNER JOIN " . TABLE_PREFIX . "attachment AS attachment ON (attachment.postid=post.postid AND attachment.visible=1)
WHERE threadid = $threadinfo[threadid]
AND post.visible = 1
ORDER BY filename DESC
LIMIT 5
");
if ($db->num_rows($attachs))
{
while ($attachment = $db->fetch_array($attachs))
{
$strImages = "<meta property=\"og:image\" content=\"/attachment.php?attachmentid=$attachment[attachmentid]&d=$attachment[dateline]\" />"
}
}
仅供参考 - facebook 似乎以相反的方式添加缩略图。他们将查看最后一个 og:image 并将其用作第一个缩略图;显示的下一个缩略图将是倒数第二个,依此类推。如果这很重要,可能想要使用 SQL 的排序顺序。此外,image_src 链接用于非开放图形社交网站(google plus、twitter)