Click here to Skip to main content
15,314,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
trying to send a dm but i failed is there a way to make this work?
it returns 200 status code BUT i does not send the message !
import cloudscraper
import re
import uuid

headers={}
s = cloudscraper.create_scraper()
def log():
	global headers
	data = {'username': '','e nc_password': '','queryParams': '{}','optIntoOneTap': 'true'}
	a=s.get('https://www.instagram.com/').text
	csrf = str(re.search('csrf_token":"(.*)","viewer"',a).group(1))
	headers = {'x-csrftoken':csrf,'cookie':'csrftoken='+csrf+';'}
	print(s.post('https://www.instagram.com/accounts/login/ajax/',data=data,headers=headers).status_code)
	print(s.cookies)
	#headers = {'x-csrftoken': csrf,'cookie': 'csrftoken='+csrf+'; sessionid='+s.cookies['sessionid']+';'}
def sendMessage(target_user,msgText,csrf):
    global headers
    target_user = '[[{}]]'.format(','.join([target_user]))
    data = {
        'text': msgText,
        '_uuid': str(uuid.uuid4()),
        '_csrftoken': csrf,
        'recipient_users': target_user,
        '_uid': id
,
        'action': 'send_item',
        'client_context': str(uuid.uuid4())}
    return s.post("https://i.instagram.com/api/v1/direct_v2/threads/broadcast/text/",data=data)
log()
print(sendMessage(id,"hi",s.cookies["csrftoken"]))


What I have tried:

changing headers variable
trying to connect to websocket in the browser
changing uuid
changing message
Posted
Comments
Christian Graus 24-Jan-21 21:06pm
   
have you tried forming a call in postman?
Mr Beast 24-Jan-21 22:18pm
   
what do you mean can you debug web sockets by postman
Christian Graus 24-Jan-21 22:19pm
   
If you're making a HTTP call, you can test it there

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900