Using the facebook’s graph API to fetch group posts

Graph API Overview

The Graph API is the primary way to get data in and out of Facebook’s platform. It’s a low-level HTTP-based API that you can use to query data, post new stories, manage ads, upload photos and a variety of other tasks that an app might need to do.

The Basics

The Graph API is named after the idea of a ‘social graph’ – a representation of the information on Facebook composed of:

nodes – basically “things” such as a User, a Photo, a Page, a Comment.edges – the connections between those “things”, such as a Page’s Photos, or a Photo’s Commentsfields – info about those “things”, such as a person’s birthday, or the name of a Page

The Graph API is HTTP based, so it works with any language that has an HTTP library, such as cURL, urllib. We’ll explain a bit more about what you can do with this in the section below, but it means you can also use the Graph API directly in your browser, for example a Graph API request is equivalent to:

GET graph.facebook.com /facebook/picture? redirect=false

Most Graph API requests require the use ofaccess tokens which your app can generate by implementing Facebook Login.

This overview will show you how the Graph API can read and publish data to the social graph.

How it’s Structured

We cover this fully in our Using Graph API guide, but in general you can read APIs by making HTTP GET requests to nodes or edges on those nodes.

Almost all requests are passed to the API atgraph.facebook.com – the single exception is video uploads which use graph-video.facebook.com.

Object IDs

Each node has a unique ID which is used to access it via the Graph API. We specifically do not document any node/object ID structure or format because it is extremely likely to change over time and apps should not make assumptions based on current structure.

Here’s how you’d use the ID to make a request for a node:

GET graph.facebook.com /{node-id}

or edge:

GET graph.facebook.com /{node-id}/{edge-name}

You can generally publish to APIs by making HTTP POST requests with parameters to the node:

POST graph.facebook.com /{node-i
or edge:

POST graph.facebook.com /{node-id}/{edge-name}

Deleting via APIs is accomplished using HTTP DELETE requests (and updating via POST requests) to the same endpoints.