如何在Facebook上分享时设置标题?

时间:2015-07-06 12:12:38

标签: facebook yii2

您好我正在使用以下代码创建一个fb共享按钮

<a href="http://www.facebook.com/sharer.php?u=<<?php echo "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?>">Facebook</a>

所以使用这个我可以分享url。我也想设置标题,即在facebook分享选项中有一个字段“说出这个”。我想用默认值填充该字段。有什么办法吗? 我试过这样但是没有用

<a href="http://www.facebook.com/sharer.php?u=<<?php echo "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]&t=movie"; ?>">Facebook</a>

1 个答案:

答案 0 :(得分:1)

这是您设置标题的方式,但请继续阅读以获取更多信息。将以下元标记添加到您要共享的页面。

<meta property="og:title" content="Your Title">

&#34;对此说些什么&#34;默认你无法控制对不起。

更多信息:

您想为您的网站设置Facebook AppID,以便日后可以自定义Facebook功能。

但是下面我展示了一些基本的元标记,您需要使用它们来定制共享页面时在Facebook上显示的内容。这些会在您想要分享的每个页面上显示。更多信息在这里。 https://developers.facebook.com/docs/sharing/best-practices

<meta property="og:url" content="http://www.yoururl.com">
<meta property="og:title" content="Your Title">
<meta property="og:description" content="Your Description.">
<meta property="og:image" content="http://yoururl.com/image.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Your Site Name">
<meta property="fb:app_id" content="Your App ID (numerical)">

注意:您必须使用Facebook Open Graph Debugger删除此页面上以前存储的缓存。此外,任何以前共享的内容都很可能不受影响。