How to verify twitter login credentials

by Viper 5. June 2009 04:53

As more and more have started to integrate Twitter API into the applications and allowing user to post messages and do other twitter related tasks, one of the essential step in the work flow is to verify a user's twitter credentials. There are certain tasks you can perform without logging into API. But when it comes to posting messages or pulling a user's data etc., Twitter API wants the user to be authenticated. Here is a code snippet that shows how you can use Twitter API to verify a user's credentials or verify user's login information.


static TwitterUser VerifyTwitterCredentials(string login, string password)
{
 IFluentTwitter ft = FluentTwitter.CreateRequest();
 ft.AuthenticateAs(login, password);
 ft.Accounts().VerifyCredentials().AsJson();
 var resp = ft.Request();
 TwitterUser tUser = resp.AsUser();
 if (null == tUser)
 {
  var err = resp.AsError();
  Console.WriteLine("Twiiter Error: " + err.ErrorMessage);
 }
 return tUser;
}

When verification fails, you will get a response that will not get converted to TwitterUser object and method will return null object.

Views: 2923

Tags: ,

.Net | C# | VB.Net

Comments

9/4/2009 6:07:59 AM #

SEO

Is there any e-mail feature in twitter?

SEO United States

10/19/2009 11:45:33 AM #

cash loans

Like your writing! Still you can do some things to improve it.

cash loans United States

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.1.7
Theme by Naveen Kohli