Create a Twitter user:
http://twitter.com/
Register your application:
https://dev.twitter.com/apps/new
This gives you:
<add key=”AccessToken” value=”blahblahblah”/>
<add key=”AccessTokenSecret” value=”blahblahblah”/>
<add key=”ConsumerKey” value=”blahblahblah”/>
<add key=”ConsumerSecret” value=”blahblahblah”/>
Add it to your web.config
Go to:
http://www.twitterizer.net/downloads/
Download the Twitterizer package:
Twitterizer2-2.3.2.zip.
Add
Twitterizer2.dll and Newtonsoft.Json.dll
in your project references
Make an ASPX page with:
<div id=”homeDev”>
<fieldset style=”width: 230px”>
<legend>Development Buzz</legend>
<%=Data1%>
</fieldset>
</div>
Do this in the .CS
public partial class Home : System.Web.UI.Page
{
private string _data1;
public string Data1
{
get { return _data1; }
set { _data1 = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
ConnectTwitter();
}
protected void ConnectTwitter()
{
OAuthTokens tokens = new OAuthTokens();
tokens.AccessToken = ConfigurationManager.AppSettings[“AccessToken”];
tokens.AccessTokenSecret = ConfigurationManager.AppSettings[“AccessTokenSecret”];
tokens.ConsumerKey = ConfigurationManager.AppSettings[“ConsumerKey”];
tokens.ConsumerSecret = ConfigurationManager.AppSettings[“ConsumerSecret”];
TwitterResponse<TwitterStatusCollection> statuses = TwitterTimeline.HomeTimeline(tokens);
for (int i = 0; i < statuses.ResponseObject.Count; i++)
{
Data1 += “<p>”;
Data1 += statuses.ResponseObject[i].Text.ToString();
Data1 += “</p>”;
}
}
}
Pingback: Intro to SQL # For Twitterizer | Mike Duke Hall's .Net blog
any pointers on how to add it to the web config file? I’m stuck on the section name and type
Hey Clement,
I usually put application specific key/value pairs in the appsettings section of the web.config. So, it would go something like this:
Let me know if that works for you.
That works thanks, but I’ve got an issue referencing my ConfigurationManager. The keys are stored in ACMSettings.config (we’re using Alterian) which is referenced in the web.config file as .
Do you know what I can use to replace ConfigurationManager with in the cs file? It’s currently underlined in red 😦
fixed it, forgot to add using System.Configuration – only problem now is using the protected void ConnectTwitter() but I’m getting there.
🙂
Sounds good. Let me know if you’re getting a specific error. If it helps, here is the Twitterizer test cases that helped me get through some initial problems:
http://svn.twitterizer.net/twitterizer/trunk/Twitterizer2.TestCases/TwitterListTests.cs
I’ve still got a problem connecting, what access do I give the app in my Twitter account? It says connected host failed to respond in a timely manner.
Is there meant to be a way of identifying what user timeline I’m trying to display?