2011年11月12日 星期六

[Facebook] Graph APIs - Introduction

[The Graph API]
  • Presents a simple, consistent view of the Facebook social graph.
  • Uniformly representing objects in the graph and the connections between them.
    • Objects: ex: people, photos, events, and pages
    • Relationships connections: ex: friend relationships, shared content, and photo tags

[How to access Object]
  • Every object has a unique ID.
  • Access the properties of an object by requesting https://graph.facebook.com/ID
  • Alternatively, people and pages with usernames can be accessed using their username as an ID by https://graph.facebook.com/USERNAME
  • All responses are JSON objects.
  • Support RESTful using HTTP GET(get), POST(create), DELETE(delete).
    • ex: DELETE https://graph.facebook.com/ID?access_token=... HTTP/1.1
    • To support clients that do not support all HTTP methods (like JavaScript clients), you can alternatively issue a POST request to an object URL with the additional argument method=delete to override the HTTP method. ex:

[Access connections of Object]
  • All of the objects in the Facebook social graph are connected to each other via relationships.
    • ex: Bret Taylor is a fan of the Coca-Cola page; Bret Taylor and Arjun Banker are friends...
  • Access the connections between objects using the URL structure https://graph.facebook.com/ID/CONNECTION_TYPE.


[Query skills]
* About Objects

* About Connections
Several useful parameters that enable you to filter and page through connection data:

* Data format
  • All date fields are returned as ISO-8601 formatted strings.
  • You can optionally override the date format by specifying a "date_format" query parameter.


[Permission]
  • To get additional information about a user, you must first get their permission.
  • Different information may need different permissions, you have obtain the right permissions of access token for the user or you can not get the relative information.

[Introspection]
  • Enables you to see all of the connections an object has without knowing its type ahead of time. 
  • This feature is a useful and extensible way to find all the things your users are connected to.
  • To get this information, add metadata=1 to the object URL, and the resulting JSON will include a metadata property that lists all the supported connections for the given object. 
  • ex: See all the connections for the Developer Garage event above by fetching https://graph.facebook.com/331218348435?metadata=1.


[Search]
https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE
ex:


* Reference
- Graph API
- Graph API Explorer

沒有留言:

張貼留言