Yortw / tweetmoasharp

TweetSharp is a fast, clean wrapper around the Twitter API.
Other
72 stars 22 forks source link

Image in direct message #61

Closed xjose97x closed 5 years ago

xjose97x commented 7 years ago

how do i send an image in a direct message?

Yortw commented 7 years ago

I don't believe you can with the current library. The documentation for the existing, official API for direct messages on Twitter doesn't list anyway to attach a media id or media element;

https://dev.twitter.com/rest/reference/post/direct_messages/new

There is a new set of beta API's listed in the Twitter docs for direct messages, and this includes a section on attaching media;

https://dev.twitter.com/rest/direct-messages

https://dev.twitter.com/rest/direct-messages https://dev.twitter.com/rest/direct-messages/attaching-media

However TweetMoaSharp has not been updated to support these API's yet.

It seems this is (or at least was) a problem with other libraries too, since the API did not previously support it; https://stackoverflow.com/questions/25872420/how-to-send-an-image-as-direct-message-with-twitter-in-android

At this stage I have no specific plans to support the beta API's. When they move out of beta I might. I'd be happy to support a good PR with appropriate tests if someone else wants to do the work.

Yortw commented 5 years ago

With the new direct message API this should be possible. Please see the migration guide from Twitter (at dev.twitter.com) for how to implement the new API end points/TMS methods. For this particular use case you want to upload the media first, specifying the dm_image value for the media category, then when sending the direct message specify the mediaid returned by the upload command.