How to send a status update to twitter from your VB app

Spider-Pig247 Jan 10, 2010

  1. Spider-Pig247

    Spider-Pig247 Newbie
    0/47

    Joined:
    Nov 14, 2009
    Messages:
    45
    Likes Received:
    3
    Trophy Points:
    0
    Gender:
    Male
    This code will allow you to be able to send a twitter update to your twitter account from a VB application

    First put this into your form
    Code:
        Public Sub Tweet(ByVal userName As String, ByVal password As String, ByVal updateMessage As String)
            Try
                Dim wc As Net.WebClient = New Net.WebClient()
                wc.Credentials = New Net.NetworkCredential(userName, password)
                Net.ServicePointManager.Expect100Continue = False
                Dim updateMessageBytes As Byte() = System.Text.Encoding.UTF8.GetBytes("status=" + updateMessage)
                wc.UploadData("http://twitter.com/statuses/update.xml", updateMessageBytes)
            Catch e As Exception
                MsgBox("Make Sure Your Twitter Credentials Are Correct And That Twitter Is Up", MsgBoxStyle.Information, "Error")
            End Try
    
        End Sub
    this is the code that will send your update to the twitter sever
    but first you will need to give it your username & password as well as your status update
    to do this you need to call the Tweet event
    Code:
    Tweet(username, password, status)
    so if my username was SpiderPg & my password was 123abc and i wanted to tweet OMG XPG IS THE BEST LOLZ
    i would put
    Code:
    Tweet("SpiderPg", "123abc", "OMG XPG IS THE BEST LOLZ")
    this would go somewhere like Form_Load or button1_click etc.
    This code can be used in a WindowsApplication as well as a ConsoleApplication
     
  2. Wo

    Wookie Newbie
    0/47

    Joined:
    Apr 27, 2010
    Messages:
    10
    Likes Received:
    1
    Trophy Points:
    0
    Console:
    Xbox
    Nice, this could be pretty usefull!
     

Share This Page

Close