How to Tweet to Twitter API 1.1 with .NET using No external Libraries


#1

Hi, I would like to be able to Tweet to the Twitter API 1.1 with .NET using No external Libraries. Tweeting is pretty much all I am looking to do besides seeing the success status of the tweet and/or if it was successful connecting to twitter.

I would prefer a solution in VB.Net, but C# would be ok.

I have tested an application using an external library called twitterizer, and I can tweet just fine, but twitterizer only supports API 1.0 which is being deprecated in about a month.


#2

Hi,

There’s primarily two components you’ll need to write. Since all requests must be authenticated, you’ll need to write code to perform OAuth authentication. Twitter has documentation here, which also includes steps to build the OAuth header:

https://dev.twitter.com/docs/auth/oauth

Next, you’ll need to build the code that makes the HTTP request. You can use HttpWebRequest or HttpClient. I saw today where MS released a new beta of HttpClient for portable libraries. You’ll build your request and add the OAuth header, pointed to the Twitter API endpoint for status updates at https://dev.twitter.com/docs/api/1.1/post/statuses/update. You can do a search for “HttpWebRequest Twitter” and get plenty of examples - the exception being that many of the blog posts are old and username/password authentication has been deprecated a while ago and replaced with OAuth.

I know you would rather not use a 3rd party library, but if you decide you don’t want to write all this code and change your mind, I wrote a 3rd party library named LINQ to Twitter (http://linqtotwitter.codeplex.com/) that does support Twitter API v1.1.

Joe


#3

Ran into the same problem. I wrote something in VB.Net to do the trick. It’s got a dependency on a JSON Parser found here:

Please don’t be too tough on me… I’ve only self-taught myself to program recently and fundamentally, I’m sure it’s not so great. Pieces of it come from the TwitterVB library, but only a few select functions and pieces that won’t be affected by changes in any foreseeable oAuth Changes anyway. =]

Project is here:

Hope it works out for ya!


#4

hehe nn


#5

hi


#6

Here’s a link that helped me better understand how to send authenticated tweets with C#, .Net code ( no library ): http://www.codeproject.com/Articles/247336/Twitter-OAuth-authentication-using-Net

Note though that now Twitter API v.1.1 is the standard, so you need to change the line of code referenced in above link
from : var resource_url = "http://api.twitter.com/1/statuses/update.json
to: var resource_url = "http://api.twitter.com/1.1/statuses/update.json


#7

@JoeMayo how to you use LINQToTwitter in .NET? Your example in written in a console how do i change it for an WebApp? #TwitterAPI


#8

@MRCTESTER i get the “The remote server returned an error: (401) Unauthorized”.when i try and compiling and running the solution. How do i get it to work as a WebApp?


#9

I am new for windows 8 development… and trying to build an app for view and update status using oauth twitter api 1.1…
I tried with many sample projects but they didn’t work properly…
please anyone can give me a sample windows 8 solution project for this features… I know how to get a Consumer key ,Consumer secret, access token, and access token secret…
thanks…


#10

Joe it seems that AspNetAuthorizer is not in the package.