sending post using instagrapi

Viewed 570

Hi i am trying to send a post into Instagram using instagrapi module and I'm using photo_upload to do that but that not working here is my code :

from instagrapi import Client

print("im gonna log in")
cl = Client()
cl.login("UserName", "Password")

cl.photo_upload("picture.png", "hello this is a test from instagrapi")

but i get this error :

Traceback (most recent call last):   File "E:\HadiH2o\Documents\_MyProjects\Python\Test\Test.py", line 10, in <module>   File "C:\Users\HadiH2o\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\photo.py", line 205, in photo_upload
    upload_id, width, height = self.photo_rupload(path, upload_id)   File "C:\Users\HadiH2o\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\photo.py", line 170, in photo_rupload
    raise PhotoNotUpload(response.text, response=response, **last_json) instagrapi.exceptions.PhotoNotUpload: {"debug_info":{"retriable":false,"type":"ProcessingFailedError","message":"Request processing failed"}}

help please!

1 Answers

I found the answer to the question To send a post to Instagram, the photo format must be JPG and the photo size must be less than 1080 x 1080.

this is the code :

from pathlib import Path
from PIL import Image
from instagrapi import Client

image = Image.open("picture.jpg")
image = image.convert("RGB")
new_image = image.resize((1080, 1080))
new_image.save("new_picture.jpg")


cl = Client()
cl.login("UserName", "Password")

phot_path = "new_picture.jpg"
phot_path  = Path(phot_path)

cl.photo_upload(phot_path , "hello this is a test from instagrapi")
Related