Send direct messages using the twitter API
I'm trying to use the twitter API to send direct messages using C #, but Twitter keeps saying:
"The remote server returned an error: (401) Unauthorized."
But it doesn't make sense, because I could have used other API calls where I was logged in.
Some background information:
I created an application with these permissions: direct, direct and direct messages
I could successfully post the status to my timeline:
https://dev.twitter.com/docs/api/1/post/statuses/update
I could as well get all direct messages sent to me:
https://dev.twitter.com/docs/api/1/get/direct_messages
The problem is trying to send a direct message:
source to share
I couldn't figure out what happened yet, but I could make it work with an open source called tweetsharp. You can download it and see the code that works:
Here is some sample code
var service = new TwitterService(consumerKey, consumerSecret, accessToken, accessTokenSecret);
var user = service.VerifyCredentials();
var result = service.SendDirectMessage(recipient, message);
source to share