Need to post message to twitter from Asp.Net



I am getting an error “The remote server returned an error: (401) Unauthorized.”

i have seen in so many sites but none of them solved the problem.

I am trying to fix this problem past 2 days but iam not able to do so. Please help me with some sample codes.

This is the code am using now,


Sub TwitIt(ByVal strUser As String, ByVal strPass As String, ByVal strMessage As String)
        'this subroutine requires your ASP.NET page to have a label control with an ID of lblStatus
        'create post variable for tweet
        Dim strTweet As String = "status=" & Server.HtmlEncode(strMessage)
        'convert post variable to byte array for transmission purposes
        Dim bRequest As Byte() = System.Text.Encoding.ASCII.GetBytes(strTweet)
            'create HttpWebRequest to status update API resource
            Dim objRequest As HttpWebRequest = WebRequest.Create("")
            'pass basic authentication credentials
            objRequest.Credentials = New NetworkCredential(strUser, strPass)
            'set method to post and pass request as a form
            objRequest.Method = "POST"
            objRequest.ContentType = "application/x-www-form-urlencoded"
            'tell the server it will not receive a 100 Continue HTTP response
            objRequest.ServicePoint.Expect100Continue = False
            'set content length of request
            objRequest.ContentLength = bRequest.Length
            'capture the stream (content) of the request
            Dim objStream As Stream = objRequest.GetRequestStream()
            'put the bytes into request
            objStream.Write(bRequest, 0, bRequest.Length)
            'close the stream to complete the request
            'uncomment line below to report success
            'lblStatus.Text = "Tweet sent!"
            'You can also capture the XML response Twitter sends back
            'uncomment lines below to capture responses
          Dim objResponse As WebResponse = objRequest.GetResponse()
            Dim objReader As New StreamReader(objResponse.GetResponseStream())
            lblStatus.Text = objReader.ReadToEnd()
        Catch ex As Exception
            'uncomment line below to report ASP.NET errors
            lblStatus.Text = ex.Message
        End Try
    End Sub

This is the line which causes that problem " Dim objResponse As WebResponse = objRequest.GetResponse()

Any Help would be appreciable



The code you’ve posted uses a form of authentication that is no longer supported by the Twitter REST API: “basic auth” – this is where you pass a login and password to the API to identify yourself. Instead, you must now use [node:115,title=“OAuth”]. DotNet OpenAuth at may be useful to you.

Also helpful: [node:139].




Hello, and best wishes to all my music and living friends, from the Santa Ysabel & Julian Out Back dawn fitch & Champ