SamLogic Social Media Components - Home

SamLogic's Twitter Component: SLTwitCtrl ActiveX Control

 
Filename: SLTwitCtrl.ocx
 

 
TwitterTwitter is a social networking and microblogging service on the Internet that let users send and read short text-based messages. Every message, also known as a "tweet", can be up to 140 characters long, and can also contain links (URLs) that open other web pages or other messages on Twitter.

SLTwitCtrl is an ActiveX component (ActiveX control) from SamLogic Software that let you handle Twitter from your software, for example from your desktop application. With the SLTwitCtrl component you can post messages (tweets) directly from your application to your Twitter account - you don't need to open a web page to handle this. The ActiveX component communicates with Twitter via Twitter's REST API.

The SLTwitCtrl component can also shorten a URL in a message by using the well-known Bitly service. As mentioned above a tweet can contain a URL (a web address), but the 140 character limit makes it hard to use a full length web address for a link in a message. By using a shortening service a tweet can contain a long web addresses without taking up to many characters of the tweet. But if you don't want to use Bitly to shorten your URLs you can also let Twitter shorten the URL.
 
Before you can use the Twitter component in your application you need to register your application at Twitter. This is an easy process and you can check this page for more information.
 
Below are all properties and methods in the SLTwitCtrl ActiveX control described.

 
 
Properties
 
Name Type Description
AppName String Specifies the name of your application. This must be exactly the same application name that your registered at Twitter.
.
BitlyAPIKey String Only if you use the Bitly URL shortening service. The API key at Bitly.
.
BitlyUsername String Only if you use the Bitly URL shortening service. Your username at Bitly.
.
ConsumerKey String Specifies the consumer key for your application.
.
ConsumerSecret String Specifies the consumer secret for your application.
 .
Password String Specifies the password for the Twitter account that will receive the Twitter message (the tweet). This can be any account.
 .
ReuseToken Boolean If this property is set to True the ActiveX component will reuse previous used tokens during the authentication process with Twitter. This will speed up the communication with Twitter and allow messages to be sent faster.
.
Username String Specifies the username for the Twitter account that will receive the Twitter message (the tweet). This can be any account.
 .

Methods
 
Method Name and Description

Posting Messages / Tweets

TwitPostMessage (ByVal sMessage As String) As Boolean

Posts a message (tweet) to Twitter. The message to send is specified via the sMessage parameter. The method returns True if successful, or False if an error occurs. If an error occurs, more information can be retrieved via the TwitGetLastError and TwitGetLastResponse method.

URL Shortening

TwitShortenURL (ByVal sURL As String, ByVal iService As Integer) As String

Shortens a URL specified via the sURL parameter. The shortened URL is returned by the method. The iService parameter specifies which shortening service to use. Currently is only Bitly supported, which equals to 1 (for the parameter). You can also set the iService parameter to 0. In this case the default service will be used, which currently is also Bitly.

TwitShortenURLInMessage (ByVal sMessage As String, ByVal iService As Integer) As String

Shortens URLs in a message that is specified via the sMessage parameter. An updated message string, with shortened URLs, is returned by the method. If no URLs are found in the message string, the string is unchanged. The iService parameter specifies which shortening service to use. See the TwitShortenURL method for more information.

TwitGetURLsFromMessage (ByVal sMessage As String, sURL1 As String, sURL2 As String)

Extracts URLs from a message. Up to two URLs can be extracted with this method. The first two URLs found is retrieved. If you want to use another URL shortening service (that is not supported by the component) you use this method to get the URLs in a message. Thereafter you can replace the URLs with shortened versions.

Error handling

TwitGetLastError () As Long

Returns an error code for the last error that occurred in the ActiveX control. If this method returns 0, there is no error to report. If the error code is > 1000, Twitter API returned an error and you can use the TwitGetLastResponse method to get details about the error. A list with possible error codes is available on this web page.

TwitGetLastResponse (ByVal sReplyMessage As String)

Returns the last response from Twitter API. If an error occurs during the communication with Twitter you can call this method to check what message Twitter returned. The message is stored in the XML format.
  


Examples of use
 
You can open one of the code example pages below to get code examples on how to use the SLTwitCtrl ActiveX control. Code examples in Microsoft Visual Basic and Microsoft Visual C++ are available:
 
> Code Examples - Microsoft Visual Basic
> Code Examples - Microsoft Visual C++


Distribution / Installation
 
On this web page we will describe how to install the SLTwitCtrl component in end-users' computers and lists which files that must be distributed with your project.
  
  
   
   
    
System requirements
The ActiveX control can be used in Windows 2000, Windows XP, Windows Vista, Windows 7 and Windows 8. It can also be used in all server versions of Windows since Windows 2000 server. The control can be used in all programming languages and development platforms that supports the ActiveX technology. For example Visual Basic 6.0, Visual Basic .NET (2003-2013), Visual C#, C++ etc. The SLTwitCtrl ActiveX control supports REST v1.1, which is the API that Twitter is currently using.
  
 
< Go back
 
Part of SamLogic Social Media Components
  
Buy component
SamLogic