You are here:
ActiveXperts.com > Twitter Toolkit > How to Use ActiveXperts Twitter Toolkit > Visual Basic .NET
Quicklinks
Twitter is a popular social networking service that enables its users to send and read messages called Tweets. Tweets are text-based posts of up to 140 characters. They are displayed on the author's profile page.
Twitter users can send and receive tweets through the Twitter website or through compatible applications. Applications that want to send or receive Tweets have the option of using Twitters HTTP based RESTfull API. The ActiveXperts Twitter Toolkit provides a user friendly wrapper around Twitters own HTTP based API.
The ActiveXperts Twitter API supports the following:
This tutorial describes how the Twitter Toolkit can be integrated in Visual Basic .NET projects.
Download the Twitter Toolkit from the ActiveXperts web site and start the installation. The installation guides you through the installation process. Download now »
Launch Microsoft Visual Studio (for instance 'Microsoft Visual Studio 2005') from the Start menu. Choose 'New' from the 'File' menu and click on 'Project'. In the 'New Project' dialog, select a Visual Studio template (for instance: 'Console Application'). Select a name for the application (for instance: 'DemoApp') and a name for the solution (for instance: 'DemoSolution'). Also, select the directory where you want to store the project (for instance: 'C:\MyProjects):
(Click on the picture to enlarge)
Now that a new project has been created, you must add a reference to the ActiveXperts Twitter Toolkit in the project to be able to use the the Twitter Toolkit object. To do so, choose 'Add Reference...' from the 'Project' menu. In the 'Add Reference' dialog that pops up, select the 'COM' tab and select the 'Twitter Toolkit Type Library' as shown in the following picture:
(Click on the picture to enlarge)
Click 'OK' to close the 'Add Reference' dialog.
On top of your code, type the following line to use the Twitter Toolkit namespace:
Imports twitter-componentLib
In your Main function, declare and create the following object:
Public m_objTwitter As Twitter m_objTwitter = New Twitter()
The following code shows how to tweet a message using ASP .NET VB.
Imports System.IO
Imports twitter-componentLib
Module Tweet
Sub Main()
Dim strConsumerKeyFile As String = "", strAccessKeyFile As String = ""
Dim objTwitter As Twitter = New Twitter() ' Create instance of COM Object
Console.WriteLine("Twitter Toolkit {0}, Module {1}", objTwitter.Build, objTwitter.Module)
Console.WriteLine("Expiration Date: {0}\r\n", objTwitter.ExpirationDate)
' To enable logging,assign a valid log file to the LogFile property
' objTwitter.LogFile = "C:\\TwitterToolkit.log";
strConsumerKeyFile = "C:\Consumer.key"
strConsumerKeyFile = "C:\Access.key"
objTwitter.LoadConsumerKey(strConsumerKeyFile)
Console.WriteLine("LoadConsumerKey, result: {0})", objTwitter.LastError )
If (objTwitter.LastError <> 0) Then
Exit Sub
End If
objTwitter.LoadAccessKey(strAccessKeyFile)
Console.WriteLine("LoadAccessKey, result: {0})", objTwitter.LastError )
If (objTwitter.LastError <> 0) Then
Exit Sub
End If
objTwitter.Tweet("I'm tweeting using ActiveXperts Twitter Toolkit VB .NET Demo!")
Console.WriteLine("Tweet, result: {0}", objTwitter.LastError )
End Sub
End Module
There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/twitter-component
The Twitter Toolkit can be used by any of the following operating systems: