Sending Facebook message as specific page - facebook

I've facebook account and a fan page defined within this account.
I'm using XMPP to send private messages using the following Java code
http://yauritux.wordpress.com/2011/09/24/facebook-chat-with-smack-xmpp-api/
I can easily send and receive messages using my user id and password.
However when I try to use my page user ID I'm getting the following error:
SASL authentication PLAIN failed: not-authorized (stack below).
I tried to use pidgin but I'm getting the same error.
Let me know if you've a solution or direction on how to send a message as a page and not as a user.
Thank you in advance,
Moshe
SASL authentication PLAIN failed: not-authorized:
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:337)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
at org.jivesoftware.smack.Connection.login(Connection.java:348)
at com.maiff.was.connectors.impl.fb.FBConsoleChatApp.login(FBConsoleChatApp.java:55)
at com.maiff.was.connectors.test.ConnectorTestMain.initFB(ConnectorTestMain.java:55)
at com.maiff.was.connectors.test.ConnectorTestMain.main(ConnectorTestMain.java:18)

Pages can only "reply" to user messages, and i am not sure if it even works with XMPP. Keep in mind that the Chat API is deprecated btw: https://developers.facebook.com/docs/chat/
Meaning, after April 2015 it will not work anymore, not even with users.
For Page conversations, there is a specific API endpoint to reply to messages: https://developers.facebook.com/docs/graph-api/reference/v2.2/conversation/messages

Related

First time setup webhook. How to subscribe to `message` in the webhook setting?

I would like to have a log chat on my own server by collecting them from the chat history between user and my Facebook page.
I found the document mention about message
Next after I can verify my token using ngrok get my server connected with Facebook. Then I am looking for message.
In my understanding I have to listen to my page event. But I could not found and row mentions about it.
I found message_sends in the User. But it is not what I want.
I think document might not get uptodate. In the picture it is 2 and now it is 3.
Obviously subscription to User and select message_sends is not a correct solution on my use case. My case is user send message to my page. And my page send webhook to my chatlog server. That's all.
Question:
How to connect message on my page to my webhook url?
I have to use messenger and then Subscribe To Events

capture json message sent by facebook to bot framework

How can i track the response that was received to bot framework from facebook or any another social network ?
For example , I am sending the location on facebook ( which is not available on framework ) and i am not able to know where it's sent .
Is there any tracker on the bot framework site that can help me do that ?
There are several ways to get information about the messages sent to your bot.
Create an Azure App Insights instance and register it with the bot framework portal and the Bot Framework will send traces to your bot including exceptions, errors, etc.
Run NGROK locally on your machine and point it to your local bot in debug, and you can use the NGROK console to see the rest calls.
Inspect the post as it comes into your bot and log the message from the message context.
--jim
The message from facebook, including the location sent by user, is available from:
var facebookJson = activity.ChannelData;

Facebook Messenger Bot verification

I submitted my facebook messenger bot for app review and the rejection reason was "received no response".
I've tested my bot from my own account and some other testers that I added to my facebook app for testing.
However, when I try to test using the default Open Graph Test User I don't get any response. The Send Message API fails with error:
{"error": {"message":"(#100) No matching user found", "type":"OAuthException", ...}}
What am I doing wrong here? How can I send message to test users using the Send/Receive message API?
I had the same problem and got responses in the facebook developers community. It seems like it is confirmed bug:
https://developers.facebook.com/bugs/230322797329131/?hc_location=ufi
Update:
It seems to work now. Since Tuesday this week I can see reviewers sending messages to the bot and get responses in the messages of the page.
My problem was
I am sending recipient id instead sender id in my json data.
dict_to_send = {
'message': {'text': u'hello FB'},
'recipient': {'id': **'*sender_id_here*'**}
}
res = requests.post("https://graph.facebook.com/v2.6/me/messages?access_token=your_token_here", <br>data=json.dumps(dict_to_send), headers = {'content-type':'application/json'})
The FB application webhooks should be subscribed only for the following events:
messages
messaging_postbacks
subscribing to one of the others events might throw that exception.
source here:
https://developers.facebook.com/bugs/578746852290927/?hc_location=ufi
Answers below:
1) You shouldn't submit for App Review without testing to see if your stuff works.
2) I'm guessing you used the user ID from the Test User interface. If you read the docs more closely, you'll see that the user IDs used for Messenger Platform is different than user IDs you get from Facebook Login (which is what the test user interface shows). Read the "Send/Receive API" section under https://developers.facebook.com/docs/messenger-platform/implementation#send_message

chat.facebook.com doesn't send zero byte at the end of the cross domain policy file response

We are implementing a Facebook application where AS3(XIFF 3.1.0 lib) is used to login to Facebook chat so that the App may send some notifications to the user's friends. At this point we come across a problem regarding a cross domain policy file required by Adobe. The thing is, when the request to get a cross domain policy file from chat.facebook.com (using
Security.loadPolicyFile("xmlsocket://chat.facebook.com:5222") ) is answered from an IP address other than 69.171.241.10 the zero byte terminating the policy file is missing in the response from the server(e.g. 173.252.107.17:5222).
According to Wireshark the flow looks like below.
Request:
<policy-file-request/>
\000
Response:
<allow-access-from domain=\"*\" to-ports=\"5222\"/>
According to the Adobe recommendation "The server must send a null byte to terminate a policy file, and may thereafter close the connection; if the server does not close the connection, Flash Player or AIR does so upon receiving the terminating null byte."
Assumption: As a result the flash player considers that no policy file is received and doesn't process xmpp login to Facebook chat.
If the assumption is correct then it looks like a Facebook bug.
Any help would be greatly appreciated,
Thanks.
This does appear to be a Facebook bug. I've verified this by performing a Wireshark link against the Openfire XMPP server (which works correctly). Have reported the bug with FB:
https://developers.facebook.com/bugs/707541335928781
Good News!!!
Facebook has fixed the bug.

Page Conversations API: Error Message for More than 2 Responses

I'm working on building an app that (among other things) uses the Facebook Graph API for Pages to reply to direct messages to a page. I send a POST request to /CONVERSATION_ID/messages as per the documentation, and everything seems to be working well.
The problem I'm encountering is that the documentation claims
"Also, a page can respond not more than twice to a user's message before the user has replied back,"
but I'm not seeing this happen during my testing.
https://developers.facebook.com/docs/reference/api/page/#conversations
I've so far sent 4 responses to the message initiated by the Facebook user that I am using to test my app with, and the Graph API has not yet given me an error message. The documentation also does not say what error message is supposed to be returned if a page attempts to send more than 2 responses to a message before the user replies back.
Does anyone know what the error message is that the Graph API returns when a page attempts to send more than 2 responses to a message?
I seem to have found the answer to my own question. While I could not find official documentation for the error messages, I found unofficial documentation for them at:
http://fbdevwiki.com/wiki/Error_codes
The error code I was looking for was there:
User has sent too many messages