This project has moved and is read-only. For the latest updates, please go here.

Simple status update in Twitter

Mar 23, 2012 at 9:36 PM

Hello! I'm trying to create a console application to simply update an status in my twitter account, I've seen similar discussions throughout the forum, however, I'm new to Twitter AND C#. Anyway I'm using the LinqtoTwitterDemo and now it runs without errors, my question is very simple: What do I have to change (maybe in the method DumpJoeFriends) to update the status of my account (named ozigee123 or whatever). My application was created, I have the consumerKey and consummerSecret, etc.

Thank you :)

Mar 23, 2012 at 9:49 PM


There's a method on the TwitterContext named UpdateStatus, which you would use like this:

twitterCtx.UpdateStatus("<Your text goes here>");

You'll need to authorize with OAuth for this to work, so take the PIN option in the demo.  After you're authorized, you can call UpdateStatus.

There's an example of this in the StatusDemos.cs file.  There's more info here too:


Mar 23, 2012 at 10:25 PM

Wow! That was fast! Thank you for your response Joe.

Please, let me know if I got this correctly: I have to use the PIN option (the one that asks for a 7 digits number) right? Is there a way to avoid the user to type this and just catch it from a returned value?

Do I have to specify somewhere the name of the account of which status is going to be updated?




Mar 23, 2012 at 10:38 PM

Correct, PIN is the one that asks the user to enter the number.  There are different authorizers, but for a client application, like WPF or Console, PIN is the only one that allows you to serve multiple users.  PIN is a work-around for client apps because OAuth was originally envisioned as a way for Web apps to collaborate without forcing the user to share their password.  Essentially, the security model is designed with the best interest of the end-user in mind.

If you're building a Web application, then you would use the Web authorizer, which handles all of the HTTP redirection for you (no PIN required).  I've temporarily pulled the Web, Silverlight, and WP7 samples because they were based on Public status queries, which Twitter will be deprecating soon, and I need to re-write them. 

Here's more info on Twitter API security, OAuth, and the LINQ to Twitter implementation:


Mar 23, 2012 at 10:51 PM

I see, but, what if I'm the only one meant to use the application? I only want to create a program that updates my own status in Twitter, no multiple users, would the PIN still be necessary? Do I have to specify in the app.config the name of the account to be updated?


Mar 23, 2012 at 11:11 PM

In that case, you only need to authenticate one time, but set a breakpoint, grab all the credentials, and re-use them every time.  Twitter doesn't expire tokens.  Another option is called Single User Authorization, which is made specially for these scenarios and you would use the Single user authorizer instead of PIN.


Mar 23, 2012 at 11:29 PM

Joe, this works fine!! I was able to update my status either with or without PIN. Thank you very much. I would like to ask one last question, sorry if it's too silly, but, how did the application know which account to update? I never specified it. Is ti because it was my account the one that got the credentials I'm using? Or maybe cause it was me who was logged in when the application ran?

Thanks again,


Mar 23, 2012 at 11:49 PM

Once the authorizer is loaded with credentials, you can re-use the same instance without re-authenticating.  Did you populate all four credential items?  If only two (ConsumerKey and ConsumerSecret), then LINQ to Twitter would initiate the authentication sequence, but if you load all four credential keys/tokens you can use the authorizer without re-authenticating.  After the authentication sequece completes successfully, all four credential items will be populated and you can get to them via auth.Credentials.

LINQ to Twitter will operate on behalf of the authenticated user.  So, if the code calls Authenticate, you'll be redirected to Twitter to authorize the application.  You'll have to be logged in to authenticate.  The logged in user who gives the application permission will be the user that LINQ to Twitter operates on behalf of.  If you were the one logged in when giving permission, then calls to UpdateStatus will be with your account.


Mar 24, 2012 at 12:24 AM

Yes, I populated all four credentials, by doing this, I'm able to update my status even without being logged in, am I right?


Mar 24, 2012 at 12:46 AM



Mar 29, 2012 at 12:22 AM
Edited Mar 29, 2012 at 12:56 AM

I found it