You are here because you, who were using old Twitter API, might search how to use new Twitter API or might try to use Twitter API or something like that. The people who are using Twitter API know that Twitter API unfortunately has changed. Before, it was easy to get Tweets belongs to anybody using just one line code like this:
And then, one thing as you need to do is to parse the returned text. That was it, no big deal. But now, you have to follow some new security steps like OAuth which is for Authentication. Don’t worry, we are going to deal with it using TweetSharp which is one of Twitter Libraries. The library is ready to use.
Let’s do it!
#1 Step – Create ASP.NET MVC 4 with Empty Template on Visual Studio 2012
You don’t have to use ASP.NET MVC or the other web technologies. It’s because ASP.NET MVC is my favourite :). So you can choose one of almost all project templates which use .NET Framework.
#2 Step – Create A Controller and Name it as “Home” then Create A View as “Index“
We created the controller and the view. Now we are going to get Twitter API things(Consumer key, consumer secret etc.).
#3 Step – Getting Twitter API Things
Go to https://dev.twitter.com/apps. And then “Create a new application“.
I’m going to create a new application for this blog post. It means you’ll never use the keys and the secrets below.
You must fill out all fields marked with a red star.
Click “Create you Twitter Application”. Then go on here.
Since we’ll need the access token, click “Create my access token”
Congratulations! We have what we need. Close the browser and go back Visual Studio!
#4 Step – Open “Package Manager Console“
Type “Install-Package TweetSharp” on the console.
#5 Step – Designing Code Behind and Fetching Tweets
Now, we are ready 🙂 Let’s try it.
As you can see the screenshot above, everyhing is good. Next step is to modify the View and edit something in Controller for routing.
6# Step – Modifying Home Controller
7# Step – Modifying Index View
You might have realized that I added 3 hours to CreatedDate is according to Greenwich Mean Time(GMT). I’m in Turkey which means my time is GMT +3.
You can get some properties from the tweets which are;
#8 Step – What’s the result?
#9 Step – Download
Click this link.
I hope this post helps you as well.
Have a nice coding!