Google.Social Graph学习笔记

来源:互联网 发布:中文输入法下载 linux 编辑:程序博客网 时间:2024/06/05 00:33
完整版本:http://code.google.com/apis/socialgraph/docs/

Social Graph可以看作一个简单的推理机,可以进行更深入的处理。

1NodeCanonicalization

某个叫Brad的人,在某个网站注册后,可能有如下链接:

l  http://brad.social-network.example.com

l  http://brad.social-network.example.com/

l  http://BRAD.SOCIAL-NETWORK.EXAMPLE.COM/

l  http://social-network.example.com/viewBlog?user=brad

l  http://social-network.example.com/viewProfile?user=brad

l  http://social-network.example.com:80/viewBlog?user=brad

l  http://social-network.example.com/users/brad/data/foaf

需要将URL标准化为这样的形式:sgn://social-network.example.com/?ident=brad

有开源工具sgnodemapperproject可以做到这点。

 

2Attributes

返回的节点对象包含一系列属性:

属性名称

描述

url

The main URL for this node. Note that this may differ from the node's key in the nodes dictionary, especially when using the sgn=1 parameter.

profile

Profile URL. Typically about the person, rather than their main content.个人资料的URL

rss

RSS URL

atom

Atom URL

foaf

FOAF URL

photo

Photo/avatar URL.

fn

Name. (formatted name)

你的应用不应该局限于上面几种属性,以后可能增加更多的属性。

 

3Edge Types

All edge types from all supported formatsare mapped onto their closest XFN equivalent. Consult the XFN 1.1 documentation for details.

In summary,the XFN relation types are:

l  Identity:

*  me: a claim that the referenced URL is yours

l  Those that indicate a relation toanother person 与他人有关联的声明:

*  contact

*  acquaintance 熟人,熟知,认识

*  friend

*  met

*  co-worker 同事,合作者

*  colleague 同事,同行

*  co-resident 同居

*  neighbor

*  child

*  parent

*  sibling

*  spouse 配偶

*  kin 亲戚

*  muse

*  crush

*  date

*  sweetheart 情人,爱人

 

Other source of me links XFN之外的其它链接源

l  Fields in FOAF, such as:

*  weblog

*  homepage

*  openid

*  mbox_sha1sum, with the resultinginternal target node of the format:

sgn://mboxsha1/?pk=4caa1d6f6203d21705a00a7aca86203e82a9cf7a

·  OpenIDdelegation <link> tags, both openid.delegate and openid2.local_id.

·  FOAFdeclaration <link> tags. (i.e. if http://example.com/ has a <link>to http://example.com/my-foaf.rdf, then a me edge is created from http://example.com/to http://example.com/my-foaf.rdf)

·  mailto: queries.When querying on an email address, a directed edge of type me from mailto:foo@bar.comto sgn://mboxsha1/?pk=xxxxx... is temporarily assumed, but not stored.

MappingFOAF’s knows field 映射到FOAFknows

By default, any knowsrelation in a FOAF file is mapped to the XFN value of contact. However, in cases where asite publishes both XFN and FOAF, with a single XFN edge type, the FOAF knows mapping will be the site'sXFN edge type used.

 

4APIshttp://code.google.com/intl/zh-CN/apis/socialgraph/docs/api.html

下面几个方法是可用的:

*  lookup:low-level access to the graph. It lets you list all the edges out of or into agiven node.

*  otherme:given one or more of a person's identifiers (e.g. URLs), return otheridentifiers for that person. 给定某个人的若干URL,返回其此人它的URL

我给出了我的3个帐号:blog.sohublog.CSDNfanfou。最后返回了我在jiwai的链接,不过只指出了我在jiwai链接向CSDN的博客。

*  testparse:test your site's XFN or FOAF to see what the Social Graph API's parsers find init。测试你的站点的XFNFOAF,看看Social Graph API的解析器能从中找到什么。

 

5、使用的前提;对站点的要求:

*  To use XFN to connect sites, add rel="friend" to your link like this:<ahref="http://bradfitz.com" rel="friend">Brad</a>

*  To use FOAF, create a FOAF file and link to it from your web page. More details on FOAF.