Help with implementing Twitter in .NET app


#1

Hi all,

This is my first posting, and I hope I’m in the right place. If not, please let me know.

I’m very new to Twitter, and am trying to implement it within a .net application. The code is executed in a function envoked by button-click, as follows.

Imports Twitterizer.Framework

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Text = “” Then
Label3.Text = "Please enter your status update in
the field provided."
Else
If updateTwitterStatus(TextBox1.Text) = “Success” Then
Label3.Text = "Update Successful"
Else
Label3.Text = "An error has occurred."
End If

End If
TextBox1.Text = ""
End Sub

Function updateTwitterStatus(ByVal msg As String) As String

Dim uname, pwd As String
uname = "###"
pwd = "###"
Try
Dim twitter As New Twitter(uname, pwd)
twitter.Status.Update(msg)
updateTwitterStatus = "Success"
Return updateTwitterStatus
Catch ex As Exception
updateTwitterStatus = "Fail"
Return updateTwitterStatus
End Try

End Function

Thank you. The error returned is:

“Twitterizer.Framework.TwitterizerException: The remote server returned an error: (401) Unauthorized. —> System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at Twitterizer.Framework.TwitterRequest.PerformWebRequest(TwitterRequestData Data, String HTTPMethod) — End of inner exception stack trace — at Twitterizer.Framework.TwitterRequest.PerformWebRequest(TwitterRequestData Data, String HTTPMethod) at Twitterizer.Framework.TwitterStatusMethods.Update(String Status, Nullable`1 InReplyToStatusID) at Twitterizer.Framework.TwitterStatusMethods.Update(String Status) at newsUpload.updateTwitterStatus(String msg) in C:\Inetpub\wwwroot\newsUpload_new.aspx.vb:line 86”

Line 86 is twitter.Status.Update(msg)

By the way, I know the error is not the username and password.


#2

#3

#4