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