Wojciech Wolski
Wojciech Wolski

Reputation: 1

Facebook messenger chat pagination with websockets

I'm trying to replicate websocket request in python. I want to get paginated results of chats that appears after scrolling down the friends chats section. Seems messenger uses websocket for it. If I go to dev tools of my browser and I open messenger few websockets appears. There's a bunch of stuff in "messages" section. After I load more chats I can find the paginated chats. Of course all messages here is encoded, so it requires using https://www.base64decode.org

So I need to know how I can replicate websocket request in python that returns paginated threads id. Also it would be useful if I get sample code in websocket that returns any data from messenger.com. What I should send to server to receive specific data.

The decoded message looks like that:

2�/ls_req�8{"app_id":"772021112871879","payload":"{\"epoch_id\":7180615195663957253,\"tasks\":[{\"payload\":\"{\\\"contact_id\\\":100080397421953}\",\"queue_name\":\"cpq_v2\",\"task_id\":170,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":100051527028435}\",\"queue_name\":\"cpq_v2\",\"task_id\":171,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":100025182523918}\",\"queue_name\":\"cpq_v2\",\"task_id\":172,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":100028998702954}\",\"queue_name\":\"cpq_v2\",\"task_id\":173,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":100080816865238}\",\"queue_name\":\"cpq_v2\",\"task_id\":174,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":100074003745866}\",\"queue_name\":\"cpq_v2\",\"task_id\":175,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":102829829143646}\",\"queue_name\":\"cpq_v2\",\"task_id\":176,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":100034890368664}\",\"queue_name\":\"cpq_v2\",\"task_id\":177,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":100076469889368}\",\"queue_name\":\"cpq_v2\",\"task_id\":178,\"label\":\"207\"},{\"payload\":\"{\\\"contact_id\\\":100077931189072}\",\"queue_name\":\"cpq_v2\",\"task_id\":179,\"label\":\"207\"}],\"version_id\":\"24998883219758789\"}","request_id":56,"type":3}

The request link is wss://edge-chat.messenger.com/chat?region=odn&sid=7953856010911743&cid=62dc1068-82aa-4eea-a8a0-718b9897d6c4

And it has GET method with 101 http status. I hope I shared enough details.

Upvotes: 0

Views: 301

Answers (0)

Related Questions