in Development

Unfollow inactive twitter users using c#

As part of my efforts for continuous learning I always try to read code from others. Today I have found on Codeplex a pretty cool library that helps you with the Twitter API called Tweetinvi, which the author defines as “an intuitive C# SDK for Twitter API”.

Tweetinvi provides access to the Twitter REST API and the Twitter Stream API. It has been developed as a Portable Class Library, so it can be used from .NET Framework 4.0, Windows 8, Windows RT, Windows Phone, Mono and Android.

Just to test how it works I’ve written some basic code that helps me to unfollow inactive twitter accounts.

The first thing you need to work with the Twitter API is to obtain the credentials that will be used in the code.

image

The first time you access you will need to create an “App” and set-up the right permissions for it, in this case we will need to Read & Write. Once you have configured the permissions request your token access. If you request a token before setting up the permissions, you will need to renew it as the token is specific to the set of permissions.

Take note of the API key, API secret, Access Token and Access token secret, as those are the values you will need to authenticate with your own twitter account.

For this example I’ve just used a console application project in Visual Studio 2013, next step is to download the latest version of Tweetinvi from Codeplex and set up the references in your project. To simplify this process, just open the “Package Manager Console” by typing “nuget console” in the “Quick Launch” (CTRL + Q). Once the console is ready, type “install-package TweetinviAPI”, this will download, install and configure Tweetinvi and all the required dependencies.

Visual Studio - package manager console

Now that all is configured, you are ready to start coding against the Twitter API.

Below you can see the methods I’ve written to unfollow the people who hasn’t been active in twitter in the last X days.

Analyze hard drive space

Just a quick post to remind some tools that allow you to analyze how is distributed the hard drive space. From time to time you probably run out of space in your hard drive and you need to delete unused data. One option is to browse through the Windows Explorer and check one by one […]

Do you want a motivated person? Then, do not demotivate him

As a manager and mentor there is always a point when someone asks you what do you do to motivate your team. That’s a great question and it is something that you should be asking yourself from time to time. However, the answer is something that I’ve been changing quite often during my career. If […]

Configure your custom domain in Azure WebSites

Azure WebSites is probably one of the easiest ways to start deploying your solutions to the cloud. It allows you to create, deploy and scale any kind of website, whether it is created from one of the available templates (WordPress, Umbraco, Ghost…) or built from scratch using your favorite programming language (.NET, Python, Node.js, Java […]

.NET Gadgeteer Series: Setting up the work environment and hello world

This is the first article about .NET Gadgeter and .NET MicroFramework. Here we will see how to set up the work environment and how to code a “hello world”. For those who do not know .NET MicroFramework, it is an open source project with Apache 2.0 license that allow us developing for embedded devices using […]