I am trying to make bot using facebook messenger api. My bot is working perfectly for direct messages. Now i want to add a feature called comment bot. Like when someone comments on my page post. I would like my bot to reply to the person. I added a webhook url for feeds. When some one comments in a post i get a respone similar to the following:
{"changes":[{"field":"feed","value":{"item":"comment","sender_name":"6sense","comment_id":"127569201201434_137925500165804","sender_id":126557694635918,"post_id":"126557694635918_127569201201434","verb":"add","parent_id":"12655769463
5918_127569201201434","created_time":1507031347,"message":".."}}],"id":"126557694635918","time":1507031349}
Now from that webhook, i am trying to reply back to user using the sender_id. But i am getting a long error which is in short
{ error:
{ message: '(#100) No matching user found',
type: 'OAuthException',
code: 100,
error_subcode: 2018001,
fbtrace_id: 'EmEDxfdcnyF' } } }
I saw some sites implementing this feature. So i guess its possible. But i am not sure why its not working. I am using the same app for this.
Try private_replies API with comment_id to send private replies to user.
To use this API you need read_page_mailboxes permission.
Related
I am trying to use Sender Actions as described in the messenger Send API docs. However when I send a typing_on POST I do no see anything happen in messenger. I have tried on chrome desktop and the messenger android app.
I am able to send a mark_seen POST and this does update the chat with an icon indicating my message has been seen.
The request body looks as follows:-
{
"recipient":{
"id":"<PSID>"
},
"sender_action":"typing_on"
}
When sending mark_seen, typing_on or typing_off I always get the following response body.
{
"recipient_id": "<PSID>"
}
Are there additional steps needed to get the typing indicator to display? Does it only work on a specific platform? I cannot find any more documentation, and I am not getting any error messages, the POST status comes back OK identically when sending mark_seen or typing_on, I just can't see any effect after typing_on.
Okay I got reply from Facebook developer team on Facebook Developers group
Quote:
"This changed recently for mobile and is currently assigned to an internal team". Looks like something internal.
I am newly entered into facebook application. I want to send the message to facebook's users without mailid. I didn't possible. because i found the error is manage_mailbox is not have permission.
Let you know, how to resolve this.. I need ASAP.\
I have tried below like this
$url = "/100003508406494/inbox/";
//100006378695734
$message="Hai";
$link='http://apps.facebook.com/jobsmate';
$face=$facebook->api($url,'POST',
array(
'access_token' => $face_token,
'method'=>'publish_streem',
'message'=>$message,
'link'=>$link,
'name'=>'jobsmate',
'description'=>"$link",
'picture'=>"http://jobsmate.wisdomjobs.com/images/jobsmateicon2.jpg"
));
manage_mailbox seems to be an incorrect error message from FB. I got the same message when i was trying to post a private message using Graph API which i found out later is not possible. You have to use either FB's send dialog or use XMPP chat interface to be able to send private messages now.
I am using graph api.
Two facebook accounts who are friends.
First guy posts( id of post be : postid1) and is visible to second guy. Secondy guy likes(suceeds).
Now when second guy tries to unlike what he liked before facebook throws me the below error.
{
"error":{
"message":"(#200) Feed story publishing to other users is disabled for this application",
"type":"OAuthException",
"code":200
}
}
I am making the below http request for unlike
Delete https://graph.facebook.com:443/postid1/likes?access_token=abc
Can some one point me what's the mistake I am doing.
I created and APP on the Facebook.
Now I am trying to post a comment on the user's timeline using the Graph API but I cannot undestand what I need to do.
I already authorized the Application (I authorized this permissions: 'user_status,publish_stream,user_photos,email').
If I look on my profile -> privacy I can see that the APP can:
This app can: Post on your behalf
This app may post on your behalf, including status updates, photos and more.
Last data access:
Basic InformationToday
See details ยท Learn more
Posts on your behalf:
Who can see posts this app makes for you on your Facebook timeline?
Public
Notifications:
When to notify you?
The app sends you a notification
So this part seems OK.
On my application I do the following to try to post somenthing on my timeline (I need to post it when I am off line).
1) GET : https://graph.facebook.com/oauth/access_token?client_id=APPID&client_secret=*APP_SECRET*&grant_type=client_credentials
RESPONSE:
access_token = 422828347771671|UdQELQIf0N7krF4JUo7VwtPLTkk
2) GET: https://graph.facebook.com/search?q=myemail&type=user
RESPONSE:
_"error":_{
______"message":_"A_user_access_token_is_required_to_request_this_resource_",
______"type":_"OAuthException",
______"code":_102
___}
But reading the documentation (https://developers.facebook.com/docs/reference/api/#searching) it seems that this request does not need any kind of access token.
I also tried to add the access token, but the result is still the same.
3) I know my facebookid so I tried to use it directly:
POST: https://graph.facebook.com/100001139132403/feed
ARGUMENT:
access_token=422828347771671|UdQELQIf0N7krF4JUo7VwtPLTkk,
message=Hello
RESPONSE:
"error": {
"message": "(#200) This API call requires a valid app_id.",
"type": "OAuthException",
"code": 200
}
}
So I tried to add client_id=APPID and app_id=APPID, I tried to put one, the other and also both arguments as GET or POST but nothing changed.
I checked the APPId ad it is correct.
Do someone have any idea?
Thank you!
You cant simply generate a user access_token by querying to a URL. What you did gives the App access token and as the error say, you are trying to do something, that needs user access_token.
Refer and implement this : https://developers.facebook.com/docs/howtos/login/server-side-login/
And use that access_token for the rest of the processes.
I'm trying to post a reply to an inbox message by sending a POST request to /message_id/comments. Is this the correct way to send a reply to an inbox message ?
I'm getting the following error:
"error": {
"type": "OAuthException",
"message": "(#3) App must be on whitelist"
}
The token has every possible permission.
Do I have to ask that my app is added on a whitelist ? how to do so ?
I'm doing this in javascript+jQuery:
var params = {
access_token: token
, method: 'post'
, message: 'hi'
};
$.getJSON('https://graph.facebook.com/$message_id/comments?callback=?', params, function(json) {
});
Facebook apps by default aren't allowed to send messages on behalf of users. There is no permission you are missing. This is an extra level to prevent spam (beyond prompting the user who). You will have to contact Facebook to get your application whitelisted. I would try their developer group.
opened a support ticket right here:
http://developers.facebook.com/bugs/183144141763793?browse=search_4e8b140cbf26e6040457329
Tried all I can think of and googled for, still getting this issue
Like others have pointed out, there isn't a way to do this programmatically unless you are on Facebook's whitelist. However, I did find a way around this for my app. What I do is use Oauth to display messages from a user's FB inbox like normal. When the user clicks 'Reply' on a message, I just send them to the reply page on Facebook Mobile, like this:
$('.reply').click(function() {
var popup_window = window.open('http://touch.facebook.com/messages/compose?ids='+message_id, '_blank');
popup_window.focus();
});
Where message id is the Facebook id for the message they are replying to. In my case, I use PHP to echo the message id into a javascript variable or data-attribute when the page loads. Since the Facebook mobile page opens in a new tab, they don't even really leave my app. Since Facebook mobile has a very streamlined interface it isn't too distracting. It's not perfect, but it works and it's easier than trying to get whitelisted.