- 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
- ex: the official page for the Facebook Platform has id 19292868552, so you can fetch the object at https://graph.facebook.com/19292868552
- Alternatively, people and pages with usernames can be accessed using their username as an ID by https://graph.facebook.com/USERNAME
- ex: Since "platform" is the username for the page above, https://graph.facebook.com/platform will return what you expect.
- 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:
- Can delete a comment by issuing a POST request to https://graph.facebook.com/COMMENT_ID?method=delete
- Can delete a like by issuing a DELETE request to /OBJECT_ID/likes (since likes don't have an ID).
[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
- Choose the fields (or connections) you want returned with the "fields" query parameter.
- ex: https://graph.facebook.com/bgolub?fields=id,name,picture, only return the id, name, and picture of Ben.
- Request multiple objects in a single query using the "ids" query parameter.
- ex: https://graph.facebook.com?ids=arjun,vernal returns both profiles in the same response.
- The "ids" query parameter also accepts URLs. This is useful for finding IDs of URLs in the Open Graph.
- A special identifier me which refers to the current user. So the URL https://graph.facebook.com/me returns the active user's profile.
* About Connections
Several useful parameters that enable you to filter and page through connection data:
- limit, offset:
- until, since (a unix timestamp or any date accepted by strtotime):
* 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:
- All public posts: https://graph.facebook.com/search?q=watermelon&type=post
- People: https://graph.facebook.com/search?q=mark&type=user
- Pages: https://graph.facebook.com/search?q=platform&type=page
- Events: https://graph.facebook.com/search?q=conference&type=event
- Groups: https://graph.facebook.com/search?q=programming&type=group
- Places: https://graph.facebook.com/search?q=coffee&type=place¢er=37.76,122.427&distance=1000
- Checkins: https://graph.facebook.com/search?type=checkin
* Reference
- Graph API
- Graph API Explorer
沒有留言:
張貼留言