instagram4j / instagram4j

:camera: Instagram private API in Java
Apache License 2.0
916 stars 274 forks source link

Error trying to upload an image to instagram timeline #564

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, I am presenting the following error trying to upload an image to instagram timeline

public boolean createPost(Post post) { try { Instagram4j insta = login(); InstagramUploadPhotoRequest request = new InstagramUploadPhotoRequest(getFile(post.getContent()), post.getCaption()); insta.sendRequest(request); return true; } catch (Exception e) { return false; } }

private Instagram4j login() throws IOException { Instagram4j instagram = Instagram4j.builder().username(username).password(password).build(); instagram.setup(); instagram.login(); return instagram; }

This is the log output

`2021-02-19 14:50:04 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.Instagram4j - Setup...

2021-02-19 14:50:04 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.Instagram4j - Device ID is: android-b6763ac600831601, random id: 9742e8cd-ab4b-441a-b797-fbbe753b5a49

2021-02-19 14:50:04 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.Instagram4j - Logging with user promobiliarios and password **

2021-02-19 14:50:04 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.Instagram4j - Sending request: org.brunocvcunha.instagram4j.requests.InstagramLoginRequest

2021-02-19 14:50:06 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.requests.InstagramRequest - Reading InstagramLoginResult from {"logged_in_user":{"pk":45816920702,"username":"promobiliarios","full_name":"PROMOBILIARIOS.COM","is_private":false,"profile_pic

2021-02-19 14:50:06 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.Instagram4j - Sending request: org.brunocvcunha.instagram4j.requests.InstagramUploadPhotoRequest

2021-02-19 14:50:07 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.Instagram4j - Sending request: org.brunocvcunha.instagram4j.requests.internal.InstagramUploadResumablePhotoRequest

2021-02-19 14:50:07 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.requests.internal.InstagramUploadResumablePhotoRequest - The upload id is 1613764207258

2021-02-19 14:50:07 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.requests.InstagramRequest - Reading InstagramUploadPhotoResult from {"debug_info":{"retriable":false,"type":"ProcessingFailedError","message":"Request processing failed"}}

2021-02-19 14:50:07 [http-nio-8080-exec-1] INFO org.brunocvcunha.instagram4j.requests.InstagramUploadPhotoRequest - Upload photo result: StatusResult(status=null, message=null, spam=false, lock=false, feedback_title=null, feedback_message=null, error_type=null, checkpoint_url=null)`

jvogit commented 3 years ago

It seems you are using 1.x.x version of instagram4j which may be outdated. You may need to use latest version of this library (2.x)

Can you see if this works for instagram4j 2.x ?

Also make sure your image dimensions are within Instagram's acceptable ratios.

ghost commented 3 years ago

image dimensions are within Instagram's acceptable ratios.

Fixed with latest version

MrEAlderson commented 3 years ago

Had the same issue. The dimensions weren't the issue, instead, the format of the image caused it. Instagram only supports JPEG and will always respond with a "ProcessingFailedError" error when passing a PNG file. ImageIO.write(image, "jpg" /* instead of png */, file);