Wednesday, February 23, 2011

Simple Twitter Integration

A few posts ago I did a quick post on simple Facebook integration but in HTML . Twitter is even simpler and this method can be applied to Silverlight easy enough. First lets look at the HTML version:

<a href="http://twitter.com/share?url=http://www.HackingSilverlight.net&text=check out this awesome site&via=DavidJKelley"
>Tweet</a>

you can see that basically its just a hyper link to the twitter share URL but it adds 3 query string parameters namely URL , text and via. URL gets parsed into a short URL by twitter and then the text is inserted and then a note about what user it came from meaning in this case the twitter would be something to the effect of:

check out this awesome site http://t.co/nn6oQN8 via @DavidJKelley

keep in mind that users will have to login and the tweet will be posted as them.
In HTML rendered the above code would look like this in your browser:

Tweet

now from Silverlight in C# it is about as simple with something like:

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri("http://twitter.com/share?url=http://www.HackingSilverlight.net&text=check out this awesome site&via=DavidJKelley"), "_blank");

this would do effectively the same thing opening a new browser window and ask them to login to twitter and then let them post the same thing. Nice and simple :)

1 comment:

  1. Hi, Some one from facebook refereed your link i have book marked it nice blogs you write see Free  how to grow twitter followers here

    ReplyDelete