I’m still trying to get into the whole Tweet thing, so in an attempt to dig into it a little I took a look at the API and found out it’s pretty functional. My version of a Hello World app was having the ability to call the REST Twitter API to update my status on Twitter. I figure if I can figure out how to integrate this social networking experience into my daily routine, then why not.
To get started, I downloaded the .NET Twitter API wrapper—this makes it super easy to build .NET-based apps that communicate with Twitter. You can get it here. After you’ve downloaded the DLL, open Visual Studio 2010 and create a new Visual Web Part project. Add a reference to the Twitter.Framework.dll and then create your UI. My UI look somewhat el lamo, as you can see from the below:
However, design skills notwithstanding, I put together a fairly straightforward UI which made coding it up easy. The main (non-production) code I added is bolded as follows:
public partial class TwitterWebPartUserControl : UserControl
string strTweet = "";
string myTweetUsername = "";
string myTweetPassword = "";
protected void Page_Load(object sender, EventArgs e)
protected void btnTweet_Click(object sender, EventArgs e)
myTweetUsername = txtUsername.Text;
myTweetPassword = txtPassword.Text;
strTweet = txtbxTweet.Text;
Twitter myTweet = new Twitter(myTweetUsername, myTweetPassword);
protected void btnClear_Click(object sender, EventArgs e)
txtbxTweet.Text = "";
txtPassword.Text = "";
txtUsername.Text = "";
When you deploy and run the sample app, you have a functional web part app that enables you to submit tweets from your web part and post them to your Twitter account.
How useful is this in the long-term? Well, that remains to be seen…but it does begin to show you that integrating with SharePoint 2010 is definitely possible. You’d want to obviously add checks like character length of tweet < 140, tweet signing, Internet connectivity check, etc., etc., but the .NET wrapper enables you to do some powerful integrations.