Skip to content

Commit

Permalink
Use messenger.com URLs instead of facebook.com
Browse files Browse the repository at this point in the history
This should allow people who have only created a messenger account to
log in.

Also parse required `fb_dtsg` and `client_revision` values better.

The 2-fa flow is removed for now, I'll re-add it later.
  • Loading branch information
madsmtm committed May 6, 2020
1 parent cce947b commit 079d409
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 167 deletions.
4 changes: 3 additions & 1 deletion fbchat/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ def upload(
data = {"voice_clip": voice_clip}

j = self.session._payload_post(
"https://upload.facebook.com/ajax/mercury/upload.php", data, files=file_dict
"https://upload.messenger.com/ajax/mercury/upload.php",
data,
files=file_dict,
)

if len(j["metadata"]) != len(file_dict):
Expand Down
6 changes: 3 additions & 3 deletions fbchat/_listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Iterable, Optional, Mapping, List


HOST = "edge-chat.facebook.com"
HOST = "edge-chat.messenger.com"

TOPICS = [
# Things that happen in chats (e.g. messages)
Expand Down Expand Up @@ -271,10 +271,10 @@ def _configure_connect_options(self):

headers = {
"Cookie": get_cookie_header(
self.session._session, "https://edge-chat.facebook.com/chat"
self.session._session, "https://edge-chat.messenger.com/chat"
),
"User-Agent": self.session._session.headers["User-Agent"],
"Origin": "https://www.facebook.com",
"Origin": "https://www.messenger.com",
"Host": HOST,
}

Expand Down
Loading

0 comments on commit 079d409

Please sign in to comment.