Schmavery / facebook-chat-api

Unofficial Facebook Chat API for Nodejs
MIT License
1.93k stars 596 forks source link

how can i send message to the user who are not in my friend lists #395

Open noboundstech opened 7 years ago

noboundstech commented 7 years ago

when i am send message to my facebook friends using api.sendMessage(req.body.message, req.body.user_details.userID);

its work fine but when user are not in my friend list its stop working its give the following error Got error 1545012. This might mean that you're not part of the conversation

noboundstech commented 7 years ago

any solution for my question does it allow us to send message to my non-friend user of facebook also

Schmavery commented 7 years ago

Hmm, we originally implemented this api before message requests were a thing. Is anyone else seeing this problem?

@noboundstech Can you check if the person you send a message to receives a messaging request when you send them a message? Maybe this is just a case of a bad error message.

noboundstech commented 7 years ago

it would be very great if you can say that is these a bug ?? or we cannot send message to the Facebook user who are not in my friendlist through this module or there is any similar modules through which we can send message

bsansouci commented 7 years ago

Hey @noboundstech could you check what @Schmavery said?

Also are you messaging an existent group chat that the bot isn't part of? Who are you messaging when you get this error? Can you message those same people from the browser?

firdousalam commented 7 years ago

hi i am from nobounds, we are getting userID from facebook API now when i am trying to send message to that user with this userID then its giving error i also create a new facebook account and dont send any friend request and by some facebook api i get facebookUserID but when i am sending message using api.sendMessage(req.body.message, req.body.user_details.userID); its giving error for those people who are not my friend yet so can you tell me what wrong i am doing in this step because as per i know i just need message and facebookID to send message using api.sendMessage so where i am wrong please tell me

firdousalam commented 7 years ago

please reply my answer can we only send message to a facebook user who are my friend or can i send message to the member who are not in my friend list using this api if yes(we can send message to facebook user who are not in my friend list) that how ????????????

Schmavery commented 7 years ago

It sounds like you're using the api more or less correctly (to test, you can try sending it to someone who is your friend, maybe). If the sendMessage works when sending a message to a friend but doesn't work when sending a message to a non-friend, a couple of things could be happening:

  1. Facebook is sending a message request to this non-friend
  2. No message request is being sent
  3. You are being blocked for spammy activities (it's always a possibility, especially when sending messages to people who are not your friend).

If it is 1, then this is the behaviour that we want. There is no bug in this case. If it is 2, this might be a bug. We need to verify that this isn't the case. If it is 3, then the problem is that you need to be using the api in a different way. What exactly are you trying to use the api for? Frequently people try to send many messages very quickly to many different people, which is problematic.

Either way, as you know, this is not an official facebook api, so we usually all work together to help make it work 😄

noboundstech commented 7 years ago

no message request is going to the user

i am getting

POST /sendMessageToFacebook 200 14476.504 ms - 12 WARN Got error 1545012. This might mean that you're not part of the conversation 921156834631265

my code with facebook id

app.post('/sendMessageToFacebook', function (req, res) { req.body.user_details.userID = 921156834631265; var async = require('async'); var response_data = {}; var message_details = { senderID : req.body.user_details.userID, body : req.body.message, threadID : req.body.user_details.userID, messageID : req.body.user_details.userID, isGroup : 0 };

var login = require("facebook-chat-api"); // Create simple echo bot login({email: config.user_name, password: config.password}, function callback (err, api) { api.sendMessage(req.body.message, req.body.user_details.userID); if(err) return console.error(err);

}) })

can you tell me why i cannot send message to facebook user who are not my friend

it perfectly fine for the user who are my friend but doent work for user who are not my friend

Schmavery commented 7 years ago

@noboundstech @firdousalam It's possible that facebook has changed something in the version of the server they're exposing to your account. Unfortunately it can be pretty difficult to debug this sort of problem. Generally the idea is to perform the problematic action (in this case, sending a message to a nonfriend) in a browser with the devtools open, find the request where the message is sent, and compare that request with the request we make to try to find any differences. If you want, you can post the text of that request (or a screenshot) here in the issue. Make sure to not include your cookies as those could be used to log in.

WalasPrime commented 7 years ago

+1 Just encountered the problem while trying to send a message from a test user to another test user. No message or message request was sent. Output I got from silly mode:

verb parseAndCheckLogin for (;;);{"__ar":1,"__sf":"iw","payload":{"profiles":[]},"bootloadable":{},"ixData":{},"lid":"6422994476390132737"}
verb parseAndCheckLogin for (;;);{"__ar":1,"__sf":"iw","error":1545012,"errorSummary":"Tymczasowa awaria","errorDescription":"Wyst\u0105pi\u0142 tymczasowy b\u0142\u0
105d, spr\u00f3buj ponownie.","transientError":1,"payload":null,"bootloadable":{},"ixData":{},"lid":"6422994476871842567"}
WARN sendMessage Got error 1545012. This might mean that you're not part of the conversation 100999010491103

PL-EN translation:

errorSummary: Temporary error
errorDescription: A temporary error has occured, try again

PS. Any tips on how to gather more information about what's going on? PS2. Managed to get an EN error string

verb parseAndCheckLogin for (;;);{"__ar":1,"__sf":"iw","error":1545012,"errorSummary":"Temporary Failure","errorDescription":"There was a temporary error, please try again.","transientError":1,"payload":null,"bootloadable":{},"ixData":{},"lid":"6422996994653869286"}
Schmavery commented 7 years ago

Unfortunately this error message returned by facebook is very generic, so it's hard for us to get much out of it. You can look at my comment right above to see how you could help diagnose this issue.

bsansouci commented 7 years ago

Is this still an issue?

WalasPrime commented 7 years ago

Yes, updated error message when sending the message:

verb parseAndCheckLogin for (;;);{"__ar":1,"__sf":"j0","payload":{"profiles":[]},"bootloadable":{},"ixData":{},"lid":"6443828967817949939"}
verb parseAndCheckLogin for (;;);{"__ar":1,"__sf":"j0","error":1545012,"errorSummary":"Temporary Failure","errorDescription":"There was a temporary error, please try again.","transientError":1,"payload":null,"bootloadable":{},"ixData":{},"lid":"6443828967715400549"}
WARN sendMessage Got error 1545012. This might mean that you're not part of the conversation 109481156293537

I'm using two clients here, can't tell which parseAndCheckLogin shows up on which client. Used the current master branch.

bsansouci commented 7 years ago

mmmh I can't reproduce on my side.

I just had an idea. It's possible that FB and messenger have different IDs. I just found a facebook ID that isn't valid on messenger (www.messenger.com/t/[ID] vs www.facebook.com/[ID]). The way we've been figuring out people's IDs was by clicking on their profile picture and looking at the last number before the type=3. The URL we see is formatted like: https://www.facebook.com/photo.php?fbid=[number]&set=a.[number].[number].[ID]&type=3&theater. Pick the last number after the last . and before the next query param.

Another thing is, is there any way you could share the ID of someone that you bot can't talk to?