Question

I tried with this code to post on the wall (Twitter) of a user

if (credentials.ConsumerKey == null || credentials.ConsumerSecret == null)
             {
                 credentials.ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"];
                 credentials.ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];
             }

                auth = new MvcAuthorizer
                {
                    Credentials = credentials
                };

                auth.CompleteAuthorization(Request.Url);

                if (!auth.IsAuthorized)
                {
                    Uri specialUri = new Uri(Request.Url.ToString());
                    return auth.BeginAuthorization(specialUri);
                }

                twitterCtx = new TwitterContext(auth);

                twitterCtx.UpdateStatus("Welcome");         

Probleme : the first test goes well, I posted on the wall the second test shows this error:

Error while querying Twitter.

someone can help me to solve this problem

Thanks,

Was it helpful?

Solution

LINQ to Twitter throws a TwitterQueryException when detecting an error from Twitter. You can look at the Response property of the TwitterQueryException instance to see the message that Twitter is sending back. Another way to get a complete view of the query and Twitter's response is to use Fiddler2 to view the HTTP traffic and see what Twitter's response is.

In your case, I'm looking at the fact that you said the first post worked, but the second one doesn't. This might be caused by posting a duplicate message, which Twitter doesn't allow. If you look at any of the LINQ to Twitter demos that post a message, you'll notice that they contain a DateTime, which practically guarantees that the text of each message will be different. So, In your case, you could try this:

        twitterCtx.UpdateStatus("Welcome - " + DateTime.Now.ToString()); 

You're welcome to provide more info by posting the contents of the Response property from the TwitterQueryException. Also, for more info, I've begun a FAQ at http://linqtotwitter.codeplex.com/wikipage?title=LINQ%20to%20Twitter%20FAQ&referringTitle=Documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top