Open fsarihan opened 7 years ago
They are just empty objects? Can you show some short sample code with this problem? Does it work when you don't log in as page?
Not empty objects, nothing directly and yes it works when i login as normal user without page.
{
email: "mail",
password: "pass"
},
{
pageID: "pageid"
},
function callback (err, api) {
if(err) return console.error(err);
api.setOptions({
logLevel: "silent"
});
api.setOptions({
listenEvents: true
});
var stopListening = api.listen(function(err, event) {
if(err) return console.error(err);
console.log(event) // -> Nothing comes here
switch(event.type) {
case "message":
mesajAl(event.threadID,event.body,'2');
break;
}
});
can you set the logLevel to verbose and provide a copy of the logs? The page support doesn't end up getting a whole lot of use because of the existence of some official support for messaging as page, so there may be some wrinkles to iron out.
info login Logging in...
info login Logged in
info login Request to reconnect
info login Request to pull 1
info login Request to pull 2
info login Request to thread_sync
info login Done logging in.
verb parseAndCheckLogin for (;;); {"t":"lb","lb_info":{"sticky":"433","pool":"frc3c09_chat-proxy"}}
info listen NaN
verb parseAndCheckLogin for (;;); {"t":"msg","seq":2,"u":100000289614898,"ms":[{"type":"qprimer","made":"1492719947927"},{"type":"chatproxy-presence","buddyList":{"1180251256":{"lat":1492713992},"802891389":{"lat":1492718496},"724700101":{"lat":1492642605},"1436817902":{"lat":1492719629,"p":0,"vc":8},"1317319823":{"lat":1492712776},"1075497605":{"lat":1492713365}},"userIsIdle":false,"chatNotif":0,"gamers":[]}]}
info listen NaN
verb parseAndCheckLogin for (;;); {"t":"msg","seq":3,"u":100000289614898,"ms":[{"alert_id":1492714978777011,"markup":null,"time":1492719983,"realtime_viewer_fbid":100000289614898,"type":"notification"}]}
info listen NaN
verb parseAndCheckLogin for (;;); {"t":"msg","seq":6,"u":100000289614898,"ms":[{"nodes":[{"id":"c3Rvcnk6MTAwMDAwMjg5NjE0ODk4OjE0OTI3MTQ5Nzg3NzcwMTE6NDUxNzYxNzExNTI2Njg3","actors":[{"name":"Furkan Sar\u0131han","profile_picture":{"uri":"https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-1\/c22.22.276.276\/s50x50\/281800_2273777130699_6309517_n.jpg?_nc_ad=z-m&oh=1be0748964bf37f466506850f8acca1a&oe=59933A17"}}],"title":{"ranges":[{"offset":0,"length":9,"entity":{"url":"https:\/\/www.facebook.com\/SayDestek-1072780139522689\/"}}],"aggregated_ranges":[],"text":"SayDestek 3 yeni mesaj ald\u0131."},"application":{"id":"2530096808","name":"Sayfalar","is_facebook_app":true},"attachments":[{"media":null,"style_list":["fallback","fallback","notification_target","fallback"]}],"feedback_context":null,"attached_story":null,"icon":{"uri":"https:\/\/static.xx.fbcdn.net\/rsrc.php\/v3\/yt\/r\/C8K1hbkDbLf.png"},"seen_state":"UNSEEN_AND_UNREAD","tracking":"{\"notif_type\":\"page_message\",\"context_id\":\"1072780139522689\",\"alert_id\":\"1492714978777011\",\"unread\":1,\"microtime_sent\":\"1492719983136980\",\"content_id\":\"\"}","url":"https:\/\/www.facebook.com\/SayDestek-1072780139522689\/manager\/messages\/inbox\/?ref=notif¬if_t=page_message¬if_id=1492714978777011","creation_time":1492719983,"substory_count":0,"negative":{"subscription_level":1},"menu_options":[{"client_action":"HIDE","server_action":"Tm90aWZPcHRpb25TZXJ2ZXJBY3Rpb25Ub2tlbjsxNDkyNzE0OTc4Nzc3MDExfHsiSElERSI6IkhJREUifQ==","text":"Bu bildirimi gizle","subtext":null},{"client_action":"UNSUB","server_action":"Tm90aWZPcHRpb25TZXJ2ZXJBY3Rpb25Ub2tlbjsxNDkyNzE0OTc4Nzc3MDExfHsidHlwZSI6IjI2Iiwic3ViX3N0YXR1cyI6IiIsImxldmVsIjoiMiJ9","text":"Bu sayfa i\u00e7in yeni Mesajlar hakk\u0131ndaki bildirimleri kapat","subtext":null}],"alert_id":"100000289614898:1492714978777011","showBeep":true,"beepUpdatesOnTop":true,"beepRenderer":null,"rendererData":null,"biz_asset_id":1072780139522689,"ajaxify_url":null,"timestamp":{"time":1492719983,"text":"","verbose":"20 Nisan 2017 Per\u015fembe, 23:26"},"notif_type":"page_message","isCommunity":null,"unaggregatedTitle":{"ranges":[{"offset":0,"length":9,"entity":{"url":"https:\/\/www.facebook.com\/SayDestek-1072780139522689\/"}}],"aggregated_ranges":[],"text":"SayDestek yeni bir mesaj ald\u0131: \"test\"."},"unaggregatedActors":[{"name":"Furkan Sar\u0131han","profile_picture":{"uri":"https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-1\/c22.22.276.276\/s50x50\/281800_2273777130699_6309517_n.jpg?_nc_ad=z-m&oh=1be0748964bf37f466506850f8acca1a&oe=59933A17"}}],"sound":false}],"servertime":1492719983,"realtime_viewer_fbid":100000289614898,"type":"notification_json"},{"data":{"alert_id":1492714978777011,"content_id":1072780139522689,"href":"\/n\/100000289614898\/1492714978777011?ref=m_notif¬if_t=page_message¬if_id=1492714978777011","body":{"__html":"\u003Cspan class=\"blueName\">SayDestek\u003C\/span> 3 yeni mesaj ald\u0131."},"unread":1,"type":"page_message","app_id":2530096808,"time":"Az \u00f6nce","graphql_id":"c3Rvcnk6MTAwMDAwMjg5NjE0ODk4OjE0OTI3MTQ5Nzg3NzcwMTE6NDUxNzYxNzExNTI2Njg3","profile_pic":{"__html":"\u003Cimg src=\"https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-1\/c3.3.43.43\/p50x50\/281800_2273777130699_6309517_n.jpg?_nc_ad=z-m&oh=e25e86df3ab721d1a815e23904f0a6ed&oe=59991093\" class=\"img profpic\" height=\"43\" width=\"43\" \/>"},"profile_pic_uri":"https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-1\/c3.3.43.43\/p50x50\/281800_2273777130699_6309517_n.jpg?_nc_ad=z-m&oh=e25e86df3ab721d1a815e23904f0a6ed&oe=59991093","profile_pic_2x":{"__html":"\u003Cimg src=\"https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-1\/c7.7.86.86\/p100x100\/281800_2273777130699_6309517_n.jpg?_nc_ad=z-m&oh=9581b5285ba2df951b311045d5152a44&oe=597F3ED1\" class=\"img profpic\" height=\"43\" width=\"43\" \/>"},"profile_pic_2x_uri":"https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-1\/c7.7.86.86\/p100x100\/281800_2273777130699_6309517_n.jpg?_nc_ad=z-m&oh=9581b5285ba2df951b311045d5152a44&oe=597F3ED1","app_icon":{"__html":"\u003Cimg class=\"img\" src=\"https:\/\/static.xx.fbcdn.net\/rsrc.php\/v3\/yT\/r\/-IWvKsOGqat.png\" alt=\"\" \/>"}},"realtime_viewer_fbid":100000289614898,"type":"m_notification"},{"n":true,"i":30000,"realtime_viewer_fbid":100000289614898,"type":"notifications_sync"}]}
Sorry, I forgot to ask you to make the console.log(event)
visible somehow. Can you change it to console.log("EVENT:", event)
or something so that we can see what message gets parsed right before the callback is called with an empty object? I think this will tell us what type of message is causing the problem.
I did it this way and the console was clean. No data arriving while listening but as I said it works when I log in as a user.
When I log in as a page, the message sending function is running without error.
var stopListening = api.listen(function(err, event) {
if(err) return console.error(err);
console.log('__________________________');
console.log("EVENT:", event)
switch(event.type) {
case "message":
mesajAl(event.threadID,event.body,'2');
break;
}
});```
Same problem here. I was trying to listen page messages. I was not succeed.
i got too
Hello, same problem here since two days ago
Is anyone able to get the logs I was asking for? Basically it would help to see what events we receive right before the callback gets called with an empty object.
events are empty no response
Hi, has any been able to receive the events?
Thanks @bobland1 for the help, were @sachin221193 be able to solve the empty event response problem?
No, sadly. It has something todo with the logging in. We tried putting the pageID in the setOptions but still same empty messages
I'm pretty sure putting it in setOptions won't work properly, there's some logic that runs at login that must be broken. Just to clarify, it's not that the callback isn't getting called; the callback is being calling with an empty object?
Again. It's very difficult to diagnose this issue without proper logs. If there is a problem getting the logs let me know.
@how2945ard just posted some relevant-looking data in #479. From what I can tell, it seems that facebook has changed how they handle page messages in a fairly fundamental way. If we want to still support receiving messages as page, someone will need to go see how the browser gets the data now.
Are we sure that page support is still necessary with the official support for chatbots (https://developers.facebook.com/docs/messenger-platform/guides/quick-start)? I'd love if someone using it could explain to me why we still need to support this feature.
For me ( as a chatbot developer ), this page support is necessary to do some small things like sending stickers or get user's profile page. ( You can't send stickers through messenger platform api and that's stupid. )
@Schmavery could you give me some tips on how should i look into this?
Can you log in with your browser, open the devtools to the network tab, and see which request receives messages from pages (and what its format is)? Sharing this information is the first step.
From the inbox page ( https://www.facebook.com/fanpage/inbox/ ) we have this request ( https://2-edge-chat.facebook.com/pull?channel=p_USER_ID&seq=3&partition=-2&clientid=a76f7b&cb=84ci&idle=25&qp=y&cap=8&aiq=971921452915404%2C41099&pws=fresh&isq=46&msgs_recv=3&uid=USER_ID&viewer_uid=USER_ID&sticky_token=381&sticky_pool=atn1c09_chat-proxy&state=active&mode=stream&format=json) and its content:
for (;;); {
"t": "msg",
"seq": 9,
"u": 100016915447010,
"ms": [{
"ofd_ts": 1494255605332,
"delta": {
"attachments": [],
"body": "adsf",
"irisSeqId": "41100",
"messageMetadata": {
"actorFbId": "<SOME ID>",
"messageId": "mid.$<SOME ID>",
"offlineThreadingId": "<SOME ID>",
"tags": ["source:messenger:web"],
"threadKey": {
"otherUserFbId": "<SOME ID>"
},
"timestamp": "1494255605304"
},
"class": "NewMessage"
},
"type": "delta",
"iseq": 41100,
"queue": 971921452915404
},{
// and some other objects
}]
}
Ahh.. they must have finally converted pages to use delta events.
The event must now be handled here: https://github.com/Schmavery/facebook-chat-api/blob/b89c914ea0c0b9c02aa306e26608f8c4475f36dd/src/listen.js#L153-L173 instead of here: https://github.com/Schmavery/facebook-chat-api/blob/b89c914ea0c0b9c02aa306e26608f8c4475f36dd/src/listen.js#L223
Hopefully the signature won't have to change too much as a result.
Weird thing is that when I try to make the similar request ( changing form object from https://github.com/Schmavery/facebook-chat-api/blob/b89c914ea0c0b9c02aa306e26608f8c4475f36dd/src/listen.js#L25 to match the query string ) from facebook-chat-api, I could not find it in resData from: https://github.com/Schmavery/facebook-chat-api/blob/b89c914ea0c0b9c02aa306e26608f8c4475f36dd/src/listen.js#L71
Could anyone have found a solution to this problem?
The problem is that we are not getting fanpage messages from https://www.facebook.com/. We will only get fanpgae notifications.
We can only get fanpage messages from https://www.facebook.com/XXXXXX/inbox/ and I am not sure how can we manipulate request query string or url to make this happen.
@how2945ard @ilhamiarie As far as I can tell, the fix has been identified but not yet implemented. My comment above attempts to explain what needs to be done. If someone can confirm that this fix doesn't work, then we can keep searching.
Ping everyone, is this still an issue?
@bsansouci afaik yes, as the fix for this was never implemented
Any solution yet?
Hello, as of today, when I log in as page all events are empty. Is it general issue ? I tried with 2 different accounts and 3 different pages.