Does anyone know if there is a way with VB.Net or C# to login to
twitter, call 100 post commands, and then logout?

Here is my code for making a single post command in VB.Net.  As you
can see every time I call this function it has to login.  I would love
to have an array of url's and/or data that need to be processed for
the same username and password and having only one login.  I have
tried rearranging things several different ways with no luck.

Any help would be greatly appreciated.

---------------------------------------------------

    Public Function ExecutePostCommand(ByVal url As String, ByVal
username As String, ByVal password As String, _
        ByVal data As String) As String

        Try
            Dim request As HttpWebRequest = HttpWebRequest.Create(url)
            request.ServicePoint.Expect100Continue = False

            If Not String.IsNullOrEmpty(username) And Not
String.IsNullOrEmpty(password) Then
                request.Credentials = New NetworkCredential(username,
password)
                request.ContentType = "application/x-www-form-
urlencoded"
                request.Method = "POST"

                Dim bytes As Byte() = Encoding.UTF8.GetBytes(data)

                request.ContentLength = bytes.Length

                Dim s As Stream
                s = request.GetRequestStream
                s.Write(bytes, 0, bytes.Length)

                Dim r As HttpWebResponse
                r = request.GetResponse

                Dim sr As StreamReader
                sr = New StreamReader(r.GetResponseStream)

                Return sr.ReadToEnd

            Else
                Throw New Exception("Username or Password is Null")
            End If

        Catch ex As Exception
            Throw ex
        End Try

    End Function

Reply via email to