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)
            .ReportSpam()
            .ReportSpammer("examplespammer")
            .AsJson();

 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 Twitter.com, 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.

This entry was posted on Saturday, October 17th, 2009 at 7:01 pm and is filed under General. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses to “Help Fight Twitter Spam with TweetSharp”

  1. Benjamin Law Says:

    hi, as you mentioned that Basic auth are also include the function for report spam.

    But I can’t find the ReportSpam() when I use AuthenticateAs().

    Cna you provide some example for Basic Auth please? Thanks

  2. Benjamin Law Says:

    oops, sorry I was download the Preview 15. I got it now in Perview 16. Thanks

Leave a Reply