如何自定义 Facebook 的 sharer.php [英] How do I customize Facebook's sharer.php

查看:29
本文介绍了如何自定义 Facebook 的 sharer.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.google.com

如何自定义文本和图像.看起来 Facebook 撤下了文档.

How can I customize the text and image. It looks like Facebook pulled the docs.

推荐答案

你说的是 Facebook 在你分享链接时提取的预览图像和文本.Facebook 使用开放图谱协议来获取这些数据.

What you are talking about is the preview image and text that Facebook extracts when you share a link. Facebook uses the Open Graph Protocol to get this data.

基本上,您所要做的就是将这些 og:meta 标记放在您要共享的 URL 上 -

Essentially, all you'll have to do is place these og:meta tags on the URL that you want to share -

<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>
<meta property="fb:admins" content="USER_ID"/>
<meta property="og:description"
      content="A group of U.S. Marines, under command of
               a renegade general, take over Alcatraz and
               threaten San Francisco Bay with biological
               weapons."/>

如您所见,有图像属性和描述.当您对页面的 og:meta 标记进行更改时,您可以使用 Facebook 调试器.它会告诉您是否犯了任何错误(以及如何解决这些错误!)

As you can see there are both an image property and a description. When you make changes to your pages og:meta tags, you can test these changes using the Facebook Debugger. It will tell you if you have made any mistakes (and how to fix them!)

这篇关于如何自定义 Facebook 的 sharer.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆