Archive for October, 2009


Help Fight Twitter Spam with TweetSharp

You may have noticed a new option that recently appeared on the twitter UI:

This actually performs two operations, it blocks the user from following you and notifies the Twitter enforcement folks that you believe the person to be a spammer. You used to be able to do this second step by sending a direct message to the @spam account with the screen name of the spammer account, but not a lot of people knew about it, and most clients didn’t automate the process for you.

True to form, the twitter API folks added a new REST API for doing the same thing programatically, so hopefully we’ll start seeing clients make use of it.

To that end, we’ve added support for it to TweetSharp so if you’re building (or have already built) a client app with TweetSharp, then you can easily expose this function to your users.

Here’s the code for reporting a spammer using their screen name and OAuth:

 //this is an authenticated call, so you need to authenticate with either OAuth or Basic auth. 
 var twitter = FluentTwitter.CreateRequest()
            .AuthenticateWith(CONSUMER_KEY, CONSUMER_SECRET, 
                                     ACCESS_TOKEN, ACCESS_SECRET)

 var response = twitter.Request();  //make the request
 var spammer = response.AsUser();

You can also pass a user ID to the ReportSpammer method. If everything worked properly, you should get a user object back as the response.

Note that this doesn’t guarantee action on twitter’s part beyond looking into it. It doesn’t cause the user to be auto-banned or anything. Also, as it is on, using this method also blocks the spammer on behalf of the authenticated user, so there’s no need to make a second call to create the block.

Posted by Jason under General  •  2 Comments