How to invoke LINQ to Twitter with twitter account?

Nov 23, 2011 at 3:06 AM

Hi:

I'm new to Twitter API, and I think LINQ to Twitter is much better, so I choose that.

The sample as follow works fine: 

var twitterCtx = new TwitterContext();

            var publicTweets =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.Public
                select tweet;

            publicTweets.ToList().ForEach(
                tweet => Console.WriteLine(
                    "User Name: {0}, Tweet: {1}",
                    tweet.User.Name,
                    tweet.Text));

But the second demo as follow with account failed
	// configure the OAuth object
	var auth = new PinAuthorizer
	{
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"]
                },
                UseCompression = true,
                GoToTwitterAuthorization = pageLink => Process.Start(pageLink),
                GetPin = () =>
                {
                    // this executes after user authorizes, which begins with the call to auth.Authorize() below.
                    Console.WriteLine("\nAfter you authorize this application, Twitter will give you a 7-digit PIN Number.\n");
                    Console.Write("Enter the PIN number here: ");
                    return Console.ReadLine();
                }
            };
            // start the authorization process (launches Twitter authorization page).
            auth.Authorize();

It throw exception of error 401 in function "public string WebResponseGet(HttpWebRequest webRequest);"
twitterConsumerKey and twitterConsumerSecret is AccountID and password of my twitter for logon which is successful on twitter.com
Is there something wrong? Or if I have to register my test application on dev.twitter.com?

I just want to post a message to twitter from my WPF application, what should I do? Thanks!
Coordinator
Nov 23, 2011 at 3:23 PM

Hi,

Your username and password don't work with OAuth and you'll need to register an application at http://dev.twitter.com.  The LINQ to Twitter OAuth documentation might help too:

http://linqtotwitter.codeplex.com/wikipage?title=Learning%20to%20use%20OAuth&referringTitle=Securing%20Your%20Applications

@JoeMayo

Nov 24, 2011 at 2:38 AM

Thanks!

I have learned OAuth, and have done that.

Nov 24, 2011 at 2:38 AM
JoeMayo wrote:

Hi,

Your username and password don't work with OAuth and you'll need to register an application at http://dev.twitter.com.  The LINQ to Twitter OAuth documentation might help too:

http://linqtotwitter.codeplex.com/wikipage?title=Learning%20to%20use%20OAuth&referringTitle=Securing%20Your%20Applications

@JoeMayo

 

Thanks!

I have learned OAuth, and have done that.