Twitter Tweeting

Use this board to post your code snippets - tips and tricks
23 posts Page 1 of 3
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Twitter Tweeting
CodenStuff
Hello,

16th November 2010 - THIS METHOD NO LONGER WORKS - PLEASE SEE TWITTER API: http://dev.twitter.com/pages/libraries

I WILL REMOVE (ARCHIVE) THIS TOPIC WHEN AN UPDATED TUTORIAL BECOMES AVAILABLE


This is a requested snip on how to update your Twitter page from an application. There are many ways to do this but this is the quickest solution.

Before we do anything we need to add the following to the start of our code:
Code: Select all
Imports System.Net
To build this into your application you will need to add a "Button" and "TextBox" control to your form, in this example "TextBox1" holds the tweet message you wish to send.

Use this code within your buttons click event:
Code: Select all
Using Twitter As New WebClient            Twitter.Credentials = New NetworkCredential("USERNAME", "PASSWORD")            ServicePointManager.Expect100Continue = False            Dim MyTweet = System.Text.Encoding.UTF8.GetBytes("status=" & TextBox1.Text)            Try                Twitter.UploadData("http://twitter.com/statuses/update.xml", MyTweet)            Catch ex As Exception                MsgBox("The birds flew the nest, unable to tweet please try again in a few minutes.")            End Try        End Using
If you want to manually input your Twitter details using your application you will need to add "Button" and 3 "TextBox" controls used as follows in the code:

TextBox1 - Username
TextBox2 - Password
TextBox3 - Tweet Message

Then in the buttons click event use this code:
Code: Select all
Using Twitter As New WebClient            Twitter.Credentials = New NetworkCredential(TextBox1.Text, TextBox2.Text)            ServicePointManager.Expect100Continue = False            Dim MyTweet = System.Text.Encoding.UTF8.GetBytes("status=" & TextBox3.Text)            Try                Twitter.UploadData("http://twitter.com/statuses/update.xml", MyTweet)            Catch ex As Exception                MsgBox("The birds flew the nest, unable to tweet please try again in a few minutes.")            End Try        End Using
Cali Alec has made a brilliant Twitter application so please have a look and try it out here: viewtopic.php?f=54&t=164

Happy coding! cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: Twitter Tweeting
Nery
Well, I never understood exactly what twitter is, probably because I never used, but this seems interesting, is it used to publish anything you want, like applications, threads, conversations?

I like to see the complexity in a so small code, congratulations.
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

Re: Twitter Tweeting
Robby
thx for the article i will try this out and yea


Robby1998
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
CodemaN
VIP Access - Denied
VIP Access - Denied
Posts: 74
Joined: Fri Sep 18, 2009 3:18 pm

Re: Twitter Tweeting
CodemaN
thnxxxxxx
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: Twitter Tweeting
Mark
I decided to let you download the code instead of typing the code.
You do not have the required permissions to view the files attached to this post.
http://www.mbappz.com
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Twitter Tweeting
Lewis
I love this, it helped me, not just with twitter :D
Image
User avatar
RunarM
Hardcore Programmer
Hardcore Programmer
Posts: 508
Joined: Wed Nov 18, 2009 11:33 pm

Re: Twitter Tweeting
RunarM
Is it possible to fix something like this for facebook?
Just another day in my life.
http://www.codexvideos.com
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: Twitter Tweeting
Scottie1972
I made an app for my son to use.
I like simple code, simple is good!
Image

Plus a few extras I added.
Like a fast ad for my radio station.
Reset the username and password for a different account.
Why NOt?
Image
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Twitter Tweeting
Lewis
Hello Scottie,
Neat App not kean on the design but its for your son so basicly none of my buisness But the features look handy!
Thanks, Lewis
Image
User avatar
RunarM
Hardcore Programmer
Hardcore Programmer
Posts: 508
Joined: Wed Nov 18, 2009 11:33 pm

Re: Twitter Tweeting
RunarM
You could make it so he could see how many tweets he have posted.

On the tweet button:
LabelX.Text = LabelX.Text + 1

Just change the X to the nr. of the lable ;p
and name the label 0

code:
Code: Select all
Using Twitter As New WebClient
            Twitter.Credentials = New NetworkCredential(TextBox1.Text, TextBox2.Text)
            ServicePointManager.Expect100Continue = False
            Dim MyTweet = System.Text.Encoding.UTF8.GetBytes("status=" & TextBox3.Text)
            Try
                Twitter.UploadData("http://twitter.com/statuses/update.xml", MyTweet)
LabelX.Text = LabelX.Text + 1
            Catch ex As Exception
                MsgBox("The birds flew the nest, unable to tweet please try again in a few minutes.")
            End Try
        End Using
Just another day in my life.
http://www.codexvideos.com
23 posts Page 1 of 3
Return to “Quick Snips”