Alt text support in twurl


#1

Seems Twitter’s own twurl command line utility doesn’t support the new media/metadata/create endpoint yet either. I’m getting “401 Authorization Required” and “32 Could not authenticate you.” as response.

My guess is that it’s caused by twurl (or maybe the Ruby OAuth library it uses) automatically setting the Content-Type header to “application/x-www-form-urlencoded” instead of “application/json” as described in the API documentation. Adding it with an extra -A command line option doesn’t help.

Anyone here know enough Ruby to make twurl work correctly? I’d like to do my part to make images more accessible, but Lua is my language of choice these days, and this looks too complex for a quick hack.


Storing ext_alt_text for "video" type media
#2

Thanks - we are aware of this - feel free to raise an issue on the project on GitHub if there isn’t one open just yet. Hopefully @jaakkosf or I can take a look at this shortly.


#3

Done :slight_smile:


#4

Ah, turned out I wasn’t using the latest version of twurl ^_^; Things work as advertised in v0.9.3.
It might still be nice to make twurl add the correct Content-Type: header automatically, but this works for now.


#5

Great to hear, thanks for confirming @Kimik00! Was just about to post the below, does this look like what you did to have twurl successfully call POST media/metadata/create?

twurl -H upload.twitter.com -A "Content-Type: application/json" "/1.1/media/metadata/create.json" --raw-data '{ \
  "media_id":"692797692624265216", \
  "alt_text": { \
    "text":"dancing cat" \
  } \
}'

We can explore auto-detecting content-types a bit more in a future version or patch of the tool.


#6

The backslashes went a bit wonky there, but yes, that’s more or less what I’m using. I think in most cases -d (instead of -r/–rawdata) is enough for the content part.
twurl -H upload.twitter.com -A 'Content-Type: application/json' '/1.1/media/metadata/create.json' -r '{"media_id":"692797692624265216","alt_text":{"text":"dancing cat"}}'

Oh, maybe you’re not the correct person to report this to, but I just noticed alt text is not supported for videos. I understand the web player doesn’t have a simple HTML tag for that, but how to handle alt text is up to clients anyway, so it’d be nice if the API would pass it through for videos as well. Could you let the person in charge of that know?