Graph API Version
Graph API Reference /{conversation-id}/messages
The messages in a conversation between a person and a page.
Reading
GET /v2.9/{conversation-id}/messages HTTP/1.1
Host: graph.facebook.com/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/{conversation-id}/messages'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result *//* make the API call */
FB.api(
"/{conversation-id}/messages",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{conversation-id}/messages",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{conversation-id}/messages"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];Permissions
- A page access token with
read_page_mailboxespermission is required to view any messages in a conversation that Page is involved in. - A user access token with
read_mailboxpermission can be used to view any messages in a conversation that person is involved in. The person must be a developer of the app making the request with this token.
Fields
Returns an array of Message objects with additional fields:
| Name | Description | Type |
|---|---|---|
| A set of tags indicating the message folder and source of the message. |
|
Publishing
POST /v2.9/{conversation-id}/messages HTTP/1.1
Host: graph.facebook.com
message=This+is+a+test+message/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'POST',
'/{conversation-id}/messages',
array (
'message' => 'This is a test message',
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result *//* make the API call */
FB.api(
"/{conversation-id}/messages",
"POST",
{
"message": "This is a test message"
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);Bundle params = new Bundle();
params.putString("message", "This is a test message");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{conversation-id}/messages",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
NSDictionary *params = @{
@"message": @"This is a test message",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{conversation-id}/messages"
parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];Permissions
Pages can only reply to a message. They cannot initiate a conversation.
- A page access token for the page is required to publish a message.
Fields
| Parameter | Description | Type |
|---|---|---|
| The text of reply. This field is required. |
|
Response
| Name | Description | Type |
|---|---|---|
id | The ID of the newly created message. |
|
Deleting
You can't delete using this edge.
Updating
You can't update using this edge.