Open Graph protocol介绍

4 篇文章 0 订阅
  • 简介

Open Graph protocol允许任何web页面成为社交网络图中的富对象。例如,在facebook上用于允许任何网页具有与facebook其他对象相同的功能。

 

  • 基本元数据

要将网页转换为图形对象,需要向网页中添加基本元数据,在web页面的<head>中放置额外的<meta>标记。每页所需的四个属性是

og:title—显示的标题,例如“the rock”。
og:type-对象的类型,例如“video.movie”。
og:image-缩略图的url。
og:url-对象的规范url,将在图中用作其永久id,例如“http://www.imdb.com/title/tt0117500/”。

示例:

<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>
...
</html>

 

  • 可选元数据

以下属性对于任何对象都是可选的,通常建议使用:

og:audio—音频文件的URL。

og:video-视频文件的URL。

og:description-对象的描述信息。

og:determiner-出现在句子中这个对象的标题之前的单词。枚举(a, an, the, "", auto)。如果选择“auto”,则数据的使用者应在“a”或“an”之间进行选择。默认为""(空白)。

og:locale-区域设置。格式language_TERRITORY. 默认值为en_US

og:locale:alternate-此页可用于的其他区域设置的数组。

og:site_name-整个网站的名称。

示例:

<meta property="og:audio" content="http://example.com/bond/theme.mp3" />
<meta property="og:description" 
  content="Sean Connery found fame and fortune as the
           suave, sophisticated British agent, James Bond." />
<meta property="og:determiner" content="the" />
<meta property="og:locale" content="en_GB" />
<meta property="og:locale:alternate" content="fr_FR" />
<meta property="og:locale:alternate" content="es_ES" />
<meta property="og:site_name" content="IMDb" />
<meta property="og:video" content="http://example.com/bond/trailer.swf" />

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值