Can I send message to a page using Facebook Graph API? - facebook-graph-api

I saw that is possible to use Graph API to send message to a user, but I didn't find nothing about send message to a page. Is it possible?

It is not possible with the API, you can only reply to a User message as Page. Sending messages from Users to Pages is not really neccessary, Users can just use the Messenger for that. Prefilling would not be allowed anyway.

Related

Is it possible to send and fetch Facebook messages using Graph API for v4.0 or greater?

I want to create a web application using PHP which will allow to connect Facebook accounts with my application and once they authenticated my application can fetch inbox messages of that user and can auto reply to the messages received against authenticated Facebook accounts.
Also, allow user to send messages manually from my application to Facebook inbox.
Is this possible with Graph API or any other Facebook API which will allow me to do above mentioned things.
Some people was told that this feature is no longer available after Facebook Graph API v2.4.
and once they authenticated my application can fetch inbox messages of that user and can auto reply to the messages received against authenticated Facebook accounts.
Neither of those two things is possible.
You can not read the messages of user accounts any more, and you can not reply in their name either.
The only messaging that can be handled via API, is that between a user and a page.
Assuming you refer to Page conversations, not user conversation, see /conversations and /messages docs here:
https://developers.facebook.com/docs/graph-api/reference/page/conversations/
https://developers.facebook.com/docs/graph-api/reference/v5.0/conversation/messages

Communicating over Messenger on behalf of another user's page

I want to make a Messenger bot with Messenger platform. But this bot needs to be connected to other Facebook users' pages, not my own page. I have a Facebook app with Messenger configured. I want to let other Facebook users who are page owners to give my application a permission to post on behalf of their pages through Messenger, as well as receive messages from their pages on my app's webhook.
The Messenger Platform docs only explain how to post on behalf of your own page.
Is is possible to make this through Graph API + Messenger Platform or something else? And maybe with a few pointers how?
This is how I send my messages:
uri: 'https://graph.facebook.com/v2.6/me/messages',
qs: { access_token: PAGE_ACCESS_TOKEN },
method: 'POST',
json: messageData
So I think if you would just need them to supply you with their page access token, and then you could send messages as their page through your bot.
EDIT: I guess this only answers how to send messages as them. To receive messages too you'd need to somehow subscribe your webhook to their page, which I think you need to be an admin of to do, so I'm not sure receiving their pages messages is possible through a straightforward system like what I'm suggesting. There may be other more complex workarounds though.
EDIT2: Maybe you can give them your webhook URL and have them verify and subscribe it for you

Reading facebook direct messages

Is it possible to read direct messages using the facebook graph api? I can see a reference to a message object in the docs (http://developers.facebook.com/docs/reference/api/message/) but can’t see a call to get a collection of messages for a facebook page.
I eventually found this in the notifications call in the graph api ...
https://graph.facebook.com/id/notifications
I needed manage_notifications and read_mailbox extended permissions for this to work as well
using graph api and fql you can read messages
see https://developers.facebook.com/docs/reference/fql/ thread and message
be aware there is any difference for FB backend if a message has been sent from during online chat or while offline from chat

How to read inbox of Facebook pages using Graph API

Hi I'm developing management system for Facebook pages.
All Facebook pages are changed to sytle of timeline by the end of March, they will come to receive message from users.
So I want to add to read inbox of Facebook page, but I can't find how to read it by Graph API. ("/inbox" method is not worked with page access token.)
Please let me know how to do if you know.
Thanks,
Ogawa
I have suffered alot to find the correct url. It is totally different url compare to Profile messaging.
You can read the messages for a page by issuing an HTTP GET request to http://graph.facebook.com/PAGE_ID/conversations with a Page Access Token and read_mailbox permission.
Surprisingly you can reply for page messages also.
You can reply to a user's message by issuing an HTTP POST to http://graph.facebook.com/CONVERSATION_ID/messages
Note that a page can only reply to a user's message. It cannot initiate a private message with a user. Also, a page can respond not more than twice to a user's message before the user has replied back.
Hope that helps.
Graph api explore use this script after authenticating user, permission required
permission script:
$loginUrl = $facebook->getLoginUrl(array(
'scope'=>'email,read_mailbox,read_requests',
));
READ INBOX:
<?php
$user_mail=$facebook->api('/me?fields=id,name,inbox.limit(10)');
echo'<pre>',print_r($user_mail),'</pre>';
?>

How to track messages from Facebook API

I´m trying to track messages sent to my Facebook friends.
For example: I sent a message to James Bond, how do I know if he read it or not?
The Facebook Graph API does not support this yet - http://developers.facebook.com/docs/reference/api/message/. I suspect this is because there is no guaranteed way to see if a message has been read or not based on how the user accesses their messages.
It would also require permission tokens to be passed in a three-legged (recipient to application, recipient to sender) verification.