FaceBook API

简介:

Graph API

At Facebook's core is the social graph; people and the connections they have to everything they care about. The Graph API presents a simple, consistent view of the Facebook social graph, uniformly representing objects in the graph (e.g., people,photosevents, and pages) and the connections between them (e.g., friend relationships, shared content, and photo tags).

GraphAPI就是FaceBook的核心API, 用于替代传统的restful API.

对于FaceBook这样一个庞大的系统而言, 需要一个相对高阶抽象的API, 不然随着业务的扩展, API的规模将迅速扩大, 变得很难维护.

所以他推出Graph API, 但是抽象的东西往往会比较难以理解, 尤其是对于用惯了twitter API这种简单API的用户.

但是理解后, 你就明白这样的API是最适合facebook的, 可以说很多的借鉴了semantic web的思维

对于Facebook, 全球最大的social network, 实际就是维护了一张巨大的graph, graph中的点包含了万事万物, 而真正有价值的是点点之间的线, 万事万物都是有联系的. “不是风动,不是旗动,是心动”很好的反映了万事万物之间千丝万缕的联系呵呵

而facebook的目的应该就是收集尽可能多的线. 你看这个概念和本体建模的概念是不是很像. 从此可以看出Facebook这个公司的牛比和野心.

这样的话, 复杂问题就简单化了, 你所有的查询不外乎两种,

查看某一个点的属性

查看某一点和其他点的联系

理解了吗?

 

这两年对Twitter的研究如火如荼, 可是很少听到对Facebook社会性数据的研究, 我以前也一直纳闷, 什么原因?

原因很简单, 你拿不到重要的社会化数据

Facebook是严格权限控制的, 通过OAuth2.0, 你如果想得到任何点和其他点的联系, 必须通过这个的点的授权

好了, 说白了, 你通过API只能得到各个孤立点的信息, 而前面说了真正有价值的是点与点之间的联系, 而这些数据你是拿不到的(除非获得授权)

当然这个是出于个人隐私考虑, 但是其实也就断绝了绝大多数Facebook社会性数据的研究的可能性.

 

还是简单介绍一下Graph API, 象我上面介绍的, 其实很简单了

All objects in Facebook can be accessed in the same way:

 

All of the objects in the Facebook social graph are connected to each other via relationships

可以看出, 所有关系的查询都是需要权限的...真可惜, 不然可以产生多少有意思的场景和应用

 

除此之外, 还有两个API很有用

对象元数据

https://graph.facebook.com/331218348435?metadata=1

{ "name": "Facebook Developer Garage Austin - SXSW Edition", "metadata": { "connections": { "feed": "http://graph.facebook.com/331218348435/feed", "picture": "https://graph.facebook.com/331218348435/picture", "invited": "https://graph.facebook.com/331218348435/invited", "attending": "https://graph.facebook.com/331218348435/attending", "maybe": "https://graph.facebook.com/331218348435/maybe", "noreply": "https://graph.facebook.com/331218348435/noreply", "declined": "https://graph.facebook.com/331218348435/declined" } } } 

 

Searching

We support search for the following types of objects:

 

Facebook Query Language (FQL)

The FQL object enables running FQL queries using the Graph API. Facebook Query Language, or FQL, enables you to use a SQL-style interface to query the data exposed by the Graph API. It provides for some advanced features not available in the Graph API, including batching multiple queries into a single call.

可见FQL是基于Graph API的, 这不过更方便和好用一些, 对于有SQL经验的人

FQL也是严格权限控制的, 还句话说Graph API查不到的, FQL也查不到

Unlike SQL, the FQL FROM clause can contain only a single table. 不能连表查询

但可以使用IN
SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) 
而且比GraphAPI方便的是, 可以一次执行多条FQL语句,并返回最终结果
"query1":"SELECT uid, rsvp_status FROM event_member WHERE eid=12345678" 
"query2":"SELECT name, url, pic FROM profile WHERE id IN (SELECT uid FROM #query1)" 

 

下面列出的是Facebook可以查询的所有表, 相对于facebook那么庞大的系统而言, 表结构还是相当简单的, 大家如果要使用FQL必须先熟悉这些表

Facebook公开这些表结构, 还有个好处是可以给所有想建social network数据库提供一个参考模型, 一个标杆, 就这么建就可以了.

Tables

album

Query this table to return information about a photo album.

application

Query this table to return read-only properties about an application.

apprequest

An FQL table containing the requests sent via an app to a user.

checkin

Query this table to return information about a checkin. By default, this query returns the last 20 checkins and returns a maximum of 500 checkins.

comment

Query this table to obtain comments associated with one or more [fb:comments]

comments_info

The comments_info FQL table. Query this table to obtain XIDs for fb:comments objects associated with an application ID.

connection

Query this table to return a user's friends and the Facebook Pages to which the user is connected.

cookies

Query this table to return information about a cookie.

developer

Query this table to return the application IDs for which the specified user is listed as a developer in the Developer application.

domain

The domain table provides a read-only mapping between domain names and ids.

domain_admin

Query this table to return information about the admin of a domain.

event

Query this table to return information about an event.

event_member

Query this table to return information about a user's status for an event or see a list of events for a user.

family

Query this table to return detailed information about a user's family.

friend

Query this table to determine whether two users are linked together as friends.

friend_request

Query this table either to determine which users have sent friend requests to the logged-in user or to query whether a friend request has been sent from the logged-in user to a specific user.

friendlist

Query this table to return any friend lists owned by the specified user.

friendlist_member

Query this table to determine which users are members of a friend list.

group

Query this table to return information about a group.

group_member

Query this table to return information about the members of a group, or retrieve a list of groups of which a user is a member

insights

The insights table contains statistics about Applications, Pages and Domains

like

Query this table to return the user IDs of users who like a given Facebook object (video, note, link, photo, or album).

link

Query this table to return the links a user has posted.

link_stat

The link_stat table contains counts that show how users on Facebook are interacting with a given link.

mailbox_folder

The mailbox_folder table contains information about a user's mailbox folders.

message

Query this table to return information about messages in a thread.

note

Query this table to return the notes the current user has written or to return details for a particular note.

notification

Query this table to get the notifications for the current session user, that is, any notification that appears on http://www.facebook.com/notifications.php.

object_url

Query this table to return information about a URL in the Open Graph

page

Query this table to return information about a Facebook Page.

page_admin

Query this table to return information about which Facebook Pages the user Admins.

page_blocked_user

An FQL table that can be used to return a list of a users that are blocked from a Facebook Page.

page_fan

Query this table to return information about the user who likes a Facebook Page.

permissions

Query this table to return the permissions the current user has granted to the app.

permissions_info

Query this table to return more descriptive information about extended permissions.

photo

Query this table to return information about a photo.

photo_tag

Query this table to return information about a photo tag.

place

Query this table to return information about a place.

privacy

Query this table to return a user's privacy setting for a given object_id.

privacy_setting

Query default privacy settings for a user for a particular app

profile

Query this table to return certain (typically publicly) viewable information for a profile.

question

A Question as represented in FQL.

question_option

An option for a question, as represented in FQL.

question_option_votes

The votes on a particular option for a question, as represented in FQL.

review

Query this table to obtain reviews associated with an application, a user or both.

standard_friend_info

Query this table to determine whether two users are linked together as friends.

standard_user_info

Query this table to return standard information about a user, for use when you need analytic information only.

status

Query this table to return one or more of a user's statuses.

stream

Query this table to return posts from a user's stream or the user's profile.

stream_filter

Query this table to return a filter_key that can be used to query the stream FQL table, as seen through any content filters the user has available on Facebook.

stream_tag

Query this table to return associations between users or Facebook Pages and the items they tag in status posts.

thread

Query this table to return information about message threads in a user's Inbox.

translation

Query this table to return the native strings (original, untranslated text in your application interface) and the translated strings for your application.

unified_message

This table can be used to access information about messages in the new Facebook messaging system.

unified_thread

This table can be used to access information about threads in the new Facebook messaging system.

unified_thread_action

This table should be used to access information about subscribe and unsubscribe actions performed on a thread in the new Facebook messaging system.

unified_thread_count

This table should be used to access information about the number of threads in a folder in the new Facebook messaging system.

url_like

An FQL table containing the Open Graph URLs that the current session user has Liked.

user

Query this table to return detailed information from a user's profile.

video

The video table contains information about videos.

video_tag

The video_tag table contains information about users tagged in videos.


本文章摘自博客园,原文发布日期:2012-01-31

目录
相关文章
facebook private消息的API回复
facebook private消息的API回复
facebook private消息的API回复
|
存储 安全 算法
Conceal —— Facebook推出的android数据加密的开源APIandroid数据加密的开源API
现如今很多的智能手机,都支持把应用安装到SD卡中,这会帮用户节省很多空间,但是许多黑客也会利用这一点窃取用户的隐私。一般情况下,应用都有SD卡的读写权限,当然他也可以读取到其他应用,存储在SD卡上的数据。这意味着如果你安装了恶意的应用,他就可以轻易的获取SD卡上的所有数据。
339 0
Conceal —— Facebook推出的android数据加密的开源APIandroid数据加密的开源API
|
API 开发者 网络架构
|
8月前
|
机器学习/深度学习 算法 决策智能
【重磅开源】Facebook开源 Nevergrad:一种用于无梯度优化的开源工具
【重磅开源】Facebook开源 Nevergrad:一种用于无梯度优化的开源工具