GET operation
Get operations almost always begin with a node. A node is an individual object with a unique ID. For example, there are many Page node objects, each with a unique ID, and the Coca-Cola Page is the only one with the ID 820882001277849. To read any node, you query a specific object's ID. So, to read the Coca-Cola Page node you would query its ID.
Query using Graph API explorer
To query via Graph API explorer in this scenario, you have to specify the object id after the version number. In this case, you need to have a valid aceess token.
As showed in the above image, you can get the name and id as the result.
Query using Postman
As the initial step of the query, you need to go to Authorization tab and select 'OAuth 2.0'. Then specify 'Authorization' as a key in the Headers tab. For the value of the key, you need to specify "Bearer" + " " + User Access token.
With URL, you need to specify the object ID. The below image shows about this.
Query using CURL request
curl --header "Authorization: Bearer EAACEdEose0cBALx3pH3PxGRjZB6y644l2Th7ExQc0o7mN41qVrw4z3X1Y1QJPY0cNBN" https://graph.facebook.com/820882001277849
Here you need to specify, your access token after 'Bearer'
Getting all Posts from an object ID
According to the object ID, we can get all the post publicly available in a object ID.
Query using Graph API explorer
Query using Postman
Query using CURL request
curl --header "Authorization: Bearer EAACEdEose0cBALx3pH3PxGRjZB6y644l2Th7ExQc0o7mN41qVrw4z3X1Y1QJPY0cNBN" https://graph.facebook.com/820882001277849/feed
Getting a video/post comments in order
You can get the comments of a post using this.
And you can order results based on object creation time. To do this, use a
.order()
argument with one of the following values on either a field or edge.chronological
— orders results with the oldest created objects first.reverse_chronological
— orders results with the newest created objects first.
Query using Postman
Query using CURL request
curl --header "Authorization: Bearer EAACEdEose0cBALx3pH3PxGRjZB6y644l2Th7ExQc0o7" https://graph.facebook.com/1809938745705498?fields=comments.order\(chronological\).limit\(3\)
Publishing data to a node
Most edges allow you to publish objects to a collection on a node. You can do this by using a POST request on the node's edge. For example, you can publish a Comment on a Photo by using the Photo node's
/comments
edge:Query using CURL request
curl --header "Authorization: Bearer EAACEdEose0cBALx3pH3PxGRjZB6y644l2Th7ExQc0o7mND" https://graph.facebook.com/1809938745705498/comments?message=Awesome!
In above we have see some examples to get and post data. You can delete also like above.
Thanks :)
No comments:
Post a Comment