Download Media from Twitter private message

restapi
media
ton

#1

I have a developer who asked me to implement the ability to download a media from a private message.

After being refused due to the authentication information being required I noticed that the data sent from the twitter ton api was different if I was authenticated on Twitter.com compared to use the OAuth authentication credentials from a Twitter app.

It sems that the twitter.com version contains some kind of header. Would you please give me more information concerning this.

Here is the difference between the 2 files. On the left the twitter.com version, on the right the same file from the same url but using OAuth.

Thank you


#2

Please note that I did try to add the content-type image/jpeg but the data returned is still the same.


#3

Unfortunately we don’t currently have any API support for image access in DMs, but it’s a known request.


#4

I have seen this request and I understand that it is not supported but I do not understand what Twitter is actually returning.
Could you potentially provide more information on this?


#5

Sorry, I meant that we know that developers would like API support in this area, but at the moment we haven’t documented a formal way to work with images in DMs, so there’s not much I can do to help on this one.


#6

Alright thank you, I will be waiting eagerly for more news!


#7

hi andy, is this there a way to obtain media from DM ? or is still unsupported?


#8

I’m adding an Authorization header with oauth_consumer_key, oauth_signature_method, oauth_nonce, oauth_signature, oauth_timestamp, oauth_version and trying to get and image with a GET request but i receive e 401.


#9

In addition to @MartinRazzo it would be interested to know how the Twitter client fixes the problem of the missing header.
If the team is creating new headers directly within the client it would be interested if you could share the logic.

By providing this information, the developers can integrate this logic in their clients and the TwitterDev team will have a new endpoint available for the public without any effort!


#10

Downloading images from DMs is supported by the API, posting them is not. I believe the original docs were added in 2014 sometime. You just need to oauth the image download


#11

As mentioned in the first post of this thread, the problem is that the API is not returning the same binary as what is being uploaded.

The problem is that the binary returned by Twitter is invalid and cannot be used by any image viewer.