How to post Twitter update on my website?
We are using Twitter to send out news, and would like to post that one a page on our website, so off I went reading about what and where to do. On the Twitter dev page I found, the below:
Web ApplicationsBeing browser based, a web application or service is able to use the full web-based OAuth process which means the user has the smoothest of the authentication methods.
To authenticate your web application with Twitter you must use OAuth. Requests to use xAuth will be declined.
Web applications often support multiple users so it is important you manage the association of OAuth tokens to user identities carefully. The way you do this will be dependent on your application and setup.
Search APIThe search API does not require authentication.
Streaming APIThe streaming API supports both basic and OAuth authentication. For the time being there is no date on which basic authentication will be turned off for the streaming API so you are free to choose whichever method you wish.
If you have access to the account you wish to use with the streaming API and want to use OAuth you can find the access tokens you need under My Access Token from your application settings page on your accounts Twitter Applications.
Off to TwitterizerThis leads us to Twitterizer (http://www.twitterizer.net), I downloaded the examples
When I ran it they require a weird Consumer Key and Consumer Secret so off I went to read some more about why http://www.twitterizer.net/documentation/ and found this:
"All applications must be registered with Twitter. You can register a new application by visiting the Applications Using Twitter page on twitter.com, or the Twitter applications page on the Twitter developer portal."
Create an Application in TwitterSo I went to the portal and logged in using our twitter user name and password.
Then I created an application, where I had to describe it and provide the home page, and the Call Back URL, which I set to the page that I wanted to display the tweet.
Modifying my siteI then had to create a bin folder on my website, and copy the all the files from their bin folder but not the .data one since from the documentation that comes with the download it appeared that it was not required.
Web.config changesFirst I decided to store the app keys and tokens in the webconfig file, so in the <configuration> section I added settings using the values I got from the twitter application creation:
<add key="TwitterConsumerKey" value="?????????????" />
<add key="TwitterConsumerSecret" value="?????????????" />
<add key="TwitterAccessToken" value="?????????????" />
<add key="TwitterAccessTokenSecret" value="?????????????" />
<add key="TwitterUserName" value="??????" />
In the code section of the page
And in the page load section
//-- Set up tokens for security
OAuthTokens twTokens = new
twTokens.ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"];
twTokens.ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"];
twTokens.AccessToken = ConfigurationManager.AppSettings["TwitterAccessToken"];
twTokens.AccessTokenSecret = ConfigurationManager.AppSettings["TwitterAccessTokenSecret"];
//-- Get the latest tweet
if (userResponse.Result == RequestResult.Success)
string stTweet = userResponse.ResponseObject.Status.Text;
lblLastTweet.Text = "<b>Latest news: </b>" + stTweet.Replace("#","") ;