Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shabin-slr/fc787ca071381e577620d405787f6e1d to your computer and use it in GitHub Desktop.
Save shabin-slr/fc787ca071381e577620d405787f6e1d to your computer and use it in GitHub Desktop.
Base URL : "https://graph.facebook.com/v2.9"
1. Login API
GET "/dialog/oauth?client_id=<CLIENT ID>&redirect_uri=<REDIRECT URI>&scope=<COMMA SEPERATED SCOPES eg public_profile>";
RESPONSE "GET REQUEST ON CALLBACK URL WITH QUERY PARAM 'CODE' "
2. Get access_token for user with 'CODE' parameter
GET "/oauth/access_token?client_id=<CLIENT ID>&redirect_uri=<REDIRECT URI SAME AS ABOVE>&client_secret=<CLIENT SECRET>&code=<CODE RECEIVED IN EARLIER STEP>"
RESPONSE "JSON object containing access_token"
3.Get list of pages of a user
GET "/me/accounts?access_token=<access_token>&fields=id,created_time,message,from,to,tags,attachments"
RESPONSE "List of pages the user belongs to with following information : page name, id, category, the user's permissions on that page, page_access_token"
4. Connect page to Facebook app's WEBHOOK
POST "/{page_id}/subscribed_apps?access_token=<page_access_token of the page to connect>"
5. Read messages in a conversation
GET "/{conversation_id}/messages?access_token={page_access_token}&fields=id,created_time,message,from,to,tags,attachments"
RESPONSE "Array of messages"
6. Post message in conversation :
POST "/{conversation_id}/messages?access_token=<page_access_token>"
Request body : { "message" : "Message to send"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment