Post to your Twitter Account using VB.net


That’s right guys and gals, you can very easily and quickly post to your twitter account using Visual Basic.net.  The function below is a fully functional VB.net 2008 Twitter Posting function.

Simply call the function below as follows:

PostonTwitter(“username”,”password”,”what i want to post”)

 

Public Sub PostonTwitter(ByVal userName As String, ByVal password As String, ByVal updateMessage As String)
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)
‘Use UTF8 to get it properly encoded if you use characters like ç ã etc…
wc.UploadData(“http://twitter.com/statuses/update.xml”, updateMessageBytes)
End Sub

Advertisements

16 thoughts on “Post to your Twitter Account using VB.net

  1. Great piece of code, was really helpful…
    Can you also do something similar for posting to Blogger using VB.NET?

  2. Thanks Daniel, I’ve just used your code and converted to a CLR stored proc so I can easily post stuff off my SQL user group website out to our twitter account UKSQLUserGroup.

    Keep up the good work Daniel and thanks! Just need facebook now 🙂

  3. Getting an error
    The remote server returned an error: (401) Forbidden
    On this line wc.UploadData(“http://twitter.com/statuses/update.xml”, updateMessageBytes)

    Using VB2010

  4. Did anyone get a resolution to:
    The remote server returned an error: (401) Forbidden
    On this line wc.UploadData(“http://twitter.com/statuses/update.xml”, updateMessageBytes)

  5. I wrote this some time back… it’s entirely possible the code has changed since then. I know i was using the older method which i believe they were going to be turning off. I’ll see what i can find now and post any updates i find.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s