Skip to content
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

Support adding image descriptions #678

Open
lucaswerkmeister opened this issue Feb 10, 2017 · 5 comments
Open

Support adding image descriptions #678

lucaswerkmeister opened this issue Feb 10, 2017 · 5 comments

Comments

@lucaswerkmeister
Copy link

Twitter allows you to add descriptions (alt text) to images, to improve accessibility. It would be great if this client supported that as well.

@baedert
Copy link
Owner

baedert commented Feb 11, 2017

They do not allow that from their public REST API as far as I can see, https://blog.twitter.com/2016/alt-text-support-for-twitter-cards-and-the-rest-api mentions a 1.1/media/metadata/create.json endpoint for which "documentation [...] will soon be published", but https://dev.twitter.com/rest/reference still doesn't list it.

@Vistaus
Copy link

Vistaus commented Feb 11, 2017

@baedert I'm no dev, but it seems like twurl succesfully implemented it. Is that the way you can do it as well? (again: I'm no dev so I don't know whether this'll work or not) https://twittercommunity.com/t/alt-text-support-in-twurl/64391/5

@baedert
Copy link
Owner

baedert commented Feb 11, 2017

Umm, I don't know if that works or not, https://dev.twitter.com/rest/reference/post/media/metadata/create looks like some unfinished placeholder site (and it even links to a chunked media upload endpoint that doesn't officially exist...?)

@lucaswerkmeister
Copy link
Author

The twitter.com website seems to do mostly the same thing as twurl – this was POSTed to /i/media/metadata/create.json when I sent a tweet with a described image:

{"media_id":"830402076324794368","alt_text":{"text":"Two Agents Smith"}}

Same JSON as in comment #​5 there (modulo whitespace).

Also, the body of the subsequent POST request to /i/tweet/create contained &has_alt_text=true (along with the media ID).

@lucaswerkmeister
Copy link
Author

It looks like the required API is now properly documented on https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create:

Call this endpoint to attach additional metadata such as image alt text.

POST https://upload.twitter.com/1.1/media/metadata/create.json

{
  "media_id":"692797692624265216",
  // image alt text metadata
  "alt_text": {
    "text":"dancing cat" // Must be <= 420 chars
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants