Tweet with a image by using url

twitter4j
java

#1

Hi there,
I am using Twitter4J, in that i just want to post a tweet as text with image, with file path i am able to do that but if i am using any other url’s like (https://static.pexels.com/photos/257360/pexels-photo-257360.jpeg) it was throwing file not found error…
can anybody suggest me this


#2

The Twitter API expects raw image date (or base64 encoded image data), not an image URL. I’m not familiar with Twitter4J’s implementation, but unless it fetches the image for you, you’ll need to do that yourself, then upload the data either from a file or memory.