Comments (6)
i will add messenger codes then use as you needed
from facebook.
i will add messenger codes then use as you needed
Great, can't wait for it. Thank you
from facebook.
I also would love to see auto reply bot. I'm trying to develop my own. I already can get threads ids by one of graphql request that response with such data, but I don't know how sending message works here. Anybody can help? I think it's probably done through websocket but I'm not 100% sure.
from facebook.
I also would love to see auto reply bot. I'm trying to develop my own. I already can get threads ids by one of graphql request that response with such data, but I don't know how sending message works here. Anybody can help? I think it's probably done through websocket but I'm not 100% sure.
messenger app uses websocket and xmpp like client to communication (chat) both side (server/client). can be done auto system using messenger web api easily, but todo using private api of apk file will take times...
I will share web api at this time, after some days, will share messenger app private api.
from facebook.
I also would love to see auto reply bot. I'm trying to develop my own. I already can get threads ids by one of graphql request that response with such data, but I don't know how sending message works here. Anybody can help? I think it's probably done through websocket but I'm not 100% sure.
messenger app uses websocket and xmpp like client to communication (chat) both side (server/client). can be done auto system using messenger web api easily, but todo using private api of apk file will take times...
I will share web api at this time, after some days, will share messenger app private api.
It would be very useful if you would share how did you manage to find a request, what data it returns, why we use this request etc. I saw blog post somewhere that send graphql based on decoded binary message from websocket. For me it would help understating how it works.
So based on the blog I found I created a code that send message, maybe it'll save some time for you.
import requests
import json
import datetime
import random
import argparse
import re
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--message")
parser.add_argument("-r", "--recipient", type=int)
args = parser.parse_args()
with open('cookies.json', 'r') as f:
cookies = json.load(f)
session = requests.Session()
for cookie in cookies:
session.cookies.set(cookie['name'], cookie['value'], domain=cookie['domain'], path=cookie['path'])
inbox_html_resp = session.get("https://www.messenger.com")
inbox_html_resp.raise_for_status()
inbox_html_page = inbox_html_resp.text
dtsg = re.search(r'"DTSGInitialData",\[\],\{"token":"([^"]+)"', inbox_html_page).group(1)
device_id = re.search(r'"deviceId":"([^"]+)"', inbox_html_page).group(1)
schema_version = "4680497022042598"
script_urls = re.findall(r'src="([^"]+)"', inbox_html_page)
scripts = [session.get(url).text for url in script_urls if not url.startswith('data:')]
doc_id = next(re.search(r'id:"([0-9]+)",metadata:\{\},name:"LSPlatformGraphQLLightspeedRequestQuery"', script).group(1) for script in scripts if "LSPlatformGraphQLLightspeedRequestQuery" in script)
timestamp = int(datetime.datetime.now().timestamp() * 1000)
epoch = timestamp << 22
otid = epoch + random.randrange(2 ** 22)
send_message_resp = session.post(
"https://www.messenger.com/api/graphql/",
data={
"fb_dtsg": dtsg,
"doc_id": doc_id,
"variables": json.dumps(
{
"deviceId": device_id,
"requestId": 0,
"requestPayload": json.dumps(
{
"version_id": str(schema_version),
"tasks": [
{
"label": "46",
"payload": json.dumps(
{
"thread_id": args.recipient,
"otid": str(otid),
"source": 0,
"send_type": 1,
"text": args.message,
"initiating_source": 1,
}
),
"queue_name": str(args.recipient),
"task_id": 0,
"failure_count": None,
},
{
"label": "21",
"payload": json.dumps(
{
"thread_id": args.recipient,
"last_read_watermark_ts": timestamp,
"sync_group": 1,
}
),
"queue_name": str(args.recipient),
"task_id": 1,
"failure_count": None,
},
],
"epoch_id": epoch,
}
),
"requestType": 3,
}
),
},
)
send_message_resp.raise_for_status()
print(send_message_resp.text)
from facebook.
I also would love to see auto reply bot. I'm trying to develop my own. I already can get threads ids by one of graphql request that response with such data, but I don't know how sending message works here. Anybody can help? I think it's probably done through websocket but I'm not 100% sure.
messenger app uses websocket and xmpp like client to communication (chat) both side (server/client). can be done auto system using messenger web api easily, but todo using private api of apk file will take times...
I will share web api at this time, after some days, will share messenger app private api.
I believe pagination support while getting threads id would be very good feature.
from facebook.
Related Issues (3)
- help HOT 5
- api key & secret HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facebook.