In this code example, we are replying to a message a person sent to a Facebook Page. We use the Conversations API to get information about the message and to send a reply.
$fields = array(
);
$params = array(
);
$conversationss = (new Page(<PAGE_ID>))->getConversations(
$fields,
$params
);
$conversations_id = $conversationss[0]->id;
$params = array(
'message'=> "This is a message sent to a User.",
);
$page_send_message = $api->call(
"/".join("/", [$conversationss[0]->id, "messages", ]),
'POST',
$params,
);
fields = [
]
params = {
}
conversationss = Page(<PAGE_ID>).get_conversations(
fields=fields,
params=params,
)
conversations_id = conversationss[0].get_id()
params = {
'message': "This is a message sent to a User.",
}
page_send_message = FacebookAdsApi.get_default_api().call(
method='POST',
path=[conversationss[0].get_id(), "messages", ],
params=params,
)
APINodeList<UnifiedThread> conversationss = new Page(<PAGE_ID>, context).getConversations()
.execute();
String conversations_id = conversationss.get(0).getId();
APIResponse pageSendMessage = new APIRequest<APINode>(
context,
"",
new StringBuilder()
.append("/").append(conversationss.get(0).getFieldId()).append("/").append("messages")
.toString(),
"POST"
)
.setParam("message", "This is a message sent to a User.")
.execute();
page = FacebookAds::Page.get(<PAGE_ID>)
conversationss = page.conversations({
})
conversations_id = conversationss[0].id
print 'conversations_id:', conversations_id
params = {
'message': "This is a message sent to a User.",
}
page_send_message = FacebookAds::APIRequest.new(
:post,
[conversationss[0].id, "messages", ].join('/'),
session:FacebookAds::Session.default_session,
params:params,
).execute_now()
fields = [
];
params = {
};
let conversationss = await (new Page(<PAGE_ID>)).getConversations(
fields,
params
);
let conversations_id = conversationss[0].id;
params = {
'message': "This is a message sent to a User.",
}
page_send_message = await bizSdk.FacebookAdsApi.getDefaultApi().call(
method='POST',
path=[conversationss[0].id, "messages", ],
params=params,
)
Learn more about the Conversation API and the Messenger Platform.