Facebook read mailbox api
The Facebook Read Mailbox API!
The Facebook Read Mailbox API allows developers to access and read messages from a Facebook Page's inbox, outbox, and spam folder. This API is useful for building applications that need to interact with Facebook Pages, such as customer support chatbots, marketing automation tools, or social media management platforms.
Here's an overview of the API:
API Endpoints:
GET /{page_id}/messages
: Retrieves a list of messages in the page's inbox, outbox, or spam folder.GET /{page_id}/messages/{message_id}
: Retrieves a specific message by its ID.DELETE /{page_id}/messages/{message_id}
: Deletes a specific message.
API Parameters:
page_id
: The ID of the Facebook Page for which you want to access the mailbox.inbox
: Retrieves messages from the page's inbox (default).outbox
: Retrieves messages from the page's outbox.spam
: Retrieves messages from the page's spam folder.limit
: The number of messages to retrieve (default: 25).offset
: The starting point for the list of messages (default: 0).
API Response:
The API response includes a JSON object with the following properties:
messages
: An array of message objects, each containing:id
: The message ID.from
: The sender's name and ID.to
: The recipient's name and ID.subject
: The message subject.body
: The message body.created_time
: The timestamp when the message was created.updated_time
: The timestamp when the message was last updated.
Authentication:
To use the Facebook Read Mailbox API, you need to authenticate your application using Facebook's OAuth 2.0 authorization flow. You'll need to register your application on the Facebook Developer Platform and obtain an access token with the pages_read_engagement
permission.
Example Request:
Here's an example request to retrieve the first 25 messages from a Facebook Page's inbox:
GET https://graph.facebook.com/v13.0/{page_id}/messages?inbox=true&limit=25
Authorization: Bearer YOUR_ACCESS_TOKEN
Example Response:
{
"messages": [
{
"id": "1234567890",
"from": {
"name": "John Doe",
"id": "1234567890"
},
"to": {
"name": "Page Name",
"id": "1234567890"
},
"subject": "Hello from John",
"body": "Hello, this is a test message.",
"created_time": "2023-02-20T14:30:00+0000",
"updated_time": "2023-02-20T14:30:00+0000"
},
...
]
}
Remember to replace YOUR_ACCESS_TOKEN
with a valid access token and page_id
with the actual ID of the Facebook Page you want to access.