Facebook分享按钮:如何实施

pau*_*ith 9 html share facebook facebook-apps

我正在试图弄清楚如何实现Share按钮,就像在这里实现它一样.我希望能够让用户将指定链接发布到他们的新闻Feed,而无需任何类型的应用权限以及可添加到其中的某些可选文本.BuzzFeed是如何做到的?Facebook文档对我来说非常混乱,这就是为什么我自己很难实现它.如果有人能够布置需要采取的步骤,那就太棒了.我需要在HTML页面中放置什么?我需要创建一个Facebook应用程序吗?

Ani*_*han 8

要共享您的网页,您无需创建Facebook应用程序.

你可以把那个Facebook分享图片放在那里 href = "http://www.facebook.com/sharer.php?u=<your url>"

Facebook的按钮也允许共享.为您的网站生成该代码的代码在官方文档中.


小智 5

编辑您要共享的页面,将这些添加到头部的元标记中.

<meta property="og:image" content="http://www. XXXX url of a jpg image you want to be displayed  on shared content has to be 200x200 pixels (make it in photoshop ect.) XXXX"/>
<meta property="og:title" content="xxxx A title you want to be dispayed in shared content xxxx"/>
<meta property="og:url" content="http://www. url of the page you want shared including the slash after .com xxx .com/"/>
<meta property="og:description" content="xxxx discription of the shared content xxx "/>
Run Code Online (Sandbox Code Playgroud)

这里有一个og属性列表 - http://ogp.me/

接下来,在您想要页面上的分享按钮的位置插入

<a title="xxx Share mypage.com xxx" href="http://www.facebook.com/sharer.php? u=http://www. xxx url of page you edited above xxx .com &t=xxx a title you want to use xxx" target="_blank"><img  src="http://www. xxx an image for the share button (make it in photoshop ect.)xxx" width="xx" height="xx" alt="Share"/></a>
Run Code Online (Sandbox Code Playgroud)

显然取出xxx并留下"",如果你在测试时更改了上述任何一项,你可能必须去facebook调试器并调试它,因为它有时会保留原始内容.

希望这可以帮助