Tuesday, September 14, 2010

integrate twitter with asp.net in 3 easy steps.

Hello friends,
Here I am with new and very interesting topic which is how to integrate twitter with your application and more over the application is in WPF (windows application).

To integrate Twitter we have Twitterizer.Framework.dll
Which you can download from http://code.google.com/p/twitterizer/

Once you download that just copy Twitterizer.Framework.dll and past in your project’s bin folder.
After this set reference of twitterizer.FrameWork.dll in your project.
Once you done with this now everything will go smooth now.
To connect with Twitter you have to write following code.
Private pvt_Twt As Twitter
pvt_Twt = New Twitter(Me.txtName.Text, Me.txtPassword.Password)
Once you done with this and if any error does not come means you won half battle.
Now you have to play with above object.
Suppose you want to set new status on your twitter then. You have to write following code.
Me.pvt_Twt.Status.Update(Me.txtStatus.Text)


Now suppose you want to know information about your friends and no. of follower to them
Then you have to write following code.
Dim twfriends As TwitterUserCollection = Me.pvt_Twt.User.Friends()
Dim str As New System.Text.StringBuilder
For Each TwitterUser As Twitterizer.Framework.TwitterUser In twfriends
str.Append(“ScreenName : ” & TwitterUser.ScreenName.ToString() & vbCrLf)
str.Append(“No of Followers: ” & TwitterUser.NumberOfFollowers.ToString() & vbCrLf)
str.Append(“———————————————————–” + vbCrLf)
Next
Me.txtQuery.Text = str.ToString()



Now suppose if you want to see all status then you have to write following code
Dim twStatusCollection As New Twitterizer.Framework.TwitterStatusCollection
twStatusCollection = Me.pvt_Twt.Status.UserTimeline()
Dim str As New System.Text.StringBuilder
For Each tws As TwitterStatus In twStatusCollection
str.Append(“status: ” & tws.Text & “Created” & tws.Created.ToString() & vbCrLf)
str.Append(“User :” & tws.TwitterUser.ScreenName.ToString() + vbCrLf)
str.Append(“—————————————————–” + vbCrLf)
Next
Me.txtQuery.Text = str.ToString()

This just a sample which I tired more over you can sent direct message to user.
Delete any status. Delete and friend, with this DLL.
For learning purpose I used it and enjoyed a lot .I hope you like it and dig more to enjoy facility of twitterizer.framework.dll.
More over you can download the code from
Download link

Thanks
Rajat
The Suburbs