gotwi
gotwi copied to clipboard
[Question] How add an image to Tweet?
Hi, reading the Twitter API docs is not possible to add image when creating a new tweet (using managetweet.Create
):
Currently, isn’t a way to fully upload media using v2 of the Twitter API currently. However, you attach previously uploaded media to a Tweet. You can use media IDs that have been already uploaded using the v1 media endpoint or Twitter Media Studio. These media ids must be your own or that of an authenticated user.
But the docs say that is possible to upload media using the v1 media endpoint. It is possible do it with this library? If so, how i can do that?
Thanks so much.
@stormenergy91
Thank you for your question.
As stated in the official documentation, currently you must use the v1 API to upload media. And due to the policy of making the scope of the v2 API supported by this library, as a result, media uploads are not possible with this library.
If the v2 API exposes an endpoint for media uploads in the future, we will support it in this library as well.
I apologize for not being able to meet your expectations.
I am closing this issue as there has been no response for a long time.
Thank you very much.
@stormenergy91
I wrote up this post which has sample code: https://julianyap.com/posts/2024-03-13-1710365831/
Hi, @jyap808 does the code works for you? I was trying whatever you added in the blog and the moment I try to add image it's failing with this error " The Twitter API returned a Response with a status other than 2XX series. httpStatus="400 Bad Request" httpStatusCode=400 title="Invalid Request" detail="One or more parameters to your request was invalid."
this is what is getting sent in body {{"media":{"media_ids":["1771918326140174336"]},"text":"hello"} 0 -1}
Hi, @jyap808 does the code works for you? I was trying whatever you added in the blog and the moment I try to add image it's failing with this error " The Twitter API returned a Response with a status other than 2XX series. httpStatus="400 Bad Request" httpStatusCode=400 title="Invalid Request" detail="One or more parameters to your request was invalid."
this is what is getting sent in body {{"media":{"media_ids":["1771918326140174336"]},"text":"hello"} 0 -1}
@piyushm-dt
Yes, it works fine for me. Make sure you can Post a Tweet fine without media. You may have not set up your V2 tokens correctly.
Looks like your media is uploading fine since you have your media ID.