-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use media_id to upload media #43
Conversation
@@ -16,7 +16,7 @@ | |||
|
|||
X::MediaUploader.await_processing(client:, media:) | |||
|
|||
tweet_body = {text: "Posting media from @gem!", media: {media_ids: [media["media_id_string"]]}} | |||
tweet_body = {text: "Posting media from @gem!", media: {media_ids: [media["id"]]}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copy/pasted the example and had :
> media_category = "tweet_video" # other options include: tweet_image, tweet_gif, dm_image, dm_video, dm_gif, subtitles
=> "tweet_video"
> media = X::MediaUploader.chunked_upload(client:, file_path:, media_category:)
=>
{"id"=>"1904180809726124032",
...
> media
=>
{"id"=>"1904180809726124032",
"media_key"=>"7_1904180809726124032",
"size"=>2107842,
"expires_after_secs"=>86400,
"processing_info"=>{"state"=>"pending", "check_after_secs"=>1}}
> X::MediaUploader.await_processing(client:, media:)
=>
{"expires_after_secs"=>86392,
"id"=>"1904180809726124032",
"media_key"=>"7_1904180809726124032",
"processing_info"=>{"progress_percent"=>100, "state"=>"succeeded"},
"size"=>2107842,
"video"=>{"video_type"=>"video/mp4"}}
> tweet_body = {text: "Posting media from @gem!", media: {media_ids: [media["id"]]}}
=> {:text=>"Posting media from @gem!", :media=>{:media_ids=>["1904180809726124032"]}}
> tweet = client.post("tweets", tweet_body.to_json)
=>
{"data"=>
...
> tweet
=>
{"data"=>
{"edit_history_tweet_ids"=>["1904180958837801012"],
"id"=>"1904180958837801012",
"text"=>"Posting media from @gem! https://t.co/Sgui6sMm6U"}}
I don't see how the failing mutant test is related to my changes. |
Hey, I made this change myself right before I saw you submitted this pull request. Sorry about that. Version 0.15.1 has been released with this change. |
No problem but according to the doc, the parameter has to be media_id even for POST requests. I'm surprised that it still works with media_key but we may have the same issue if X decide to change. |
@GCorbel Can you re-submit your pull request with all of the conflicts resolved and I'll merge that and release 0.15.2? |
@GCorbel Never mind. I was able to pull in all the changes from your branch. |
X recently changed, so we have to use "media_id" instead of "media_key" in requests to upload media.
It fixes #42