subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.37k stars 684 forks source link

[BUG] DM FUNCTION NOT WORKING. #789

Closed penacova44 closed 2 years ago

penacova44 commented 2 years ago

when i try to dm someone via id this error occurs:

`Traceback (most recent call last): File "/home/tony/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 298, in _send_private_request response.raise_for_status() File "/home/tony/.local/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://i.instagram.com/api/v1/direct_v2/threads/broadcast/text/

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/tony/Desktop/Attachments-bot update/bot.py", line 23, in main() File "/home/tony/Desktop/Attachments-bot update/bot.py", line 16, in main dm(dms,'50261527101') File "/home/tony/Desktop/Attachments-bot update/bot.py", line 8, in dm bots.direct_send(text, user_id) File "/home/tony/.local/lib/python3.10/site-packages/instagrapi/mixins/direct.py", line 254, in direct_send result = self.private_request( File "/home/tony/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 445, in private_request raise e File "/home/tony/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 432, in private_request self._send_private_request(endpoint, kwargs) File "/home/tony/.local/lib/python3.10/site-packages/instagrapi/mixins/private.py", line 326, in _send_private_request raise ClientForbiddenError(e, response=e.response, last_json) instagrapi.exceptions.ClientForbiddenError: {"action":"item_ack","status_code":"403","payload":{"client_context":"6800043536242424861","message":"We're sorry, but something went wrong. Please try again."},"status":"fail"} `

adw0rd commented 2 years ago

@penacova44 works fine

In [6]: cl.direct_send("hello", [8530598273])
Out[6]: DirectMessage(id='30587418132388331727888637406871552', user_id=None, thread_id=340282366841710300942228194299150312713, timestamp=datetime.datetime(2022, 7, 18, 12, 27, 39, 492897, tzinfo=datetime.timezone.utc), item_type=None, is_shh_mode=None, reactions=None, text=None, link=None, animated_media=None, media=None, visual_media=None, media_share=None, reel_share=None, story_share=None, felix_share=None, clip=None, placeholder=None)
Prakashmaheshwaran commented 1 year ago

In [6]: cl.direct_send("hello", [8530598273]) where do get this number thingyy

adw0rd commented 1 year ago

@PrakashMahesh2729 https://adw0rd.github.io/instagrapi/usage-guide/direct.html