ActiveXperts Twitter Toolkit Add Twitter capabilities to any Windows or .NET application

Quicklinks


How to use Twitter Toolkit with ASP 2.x

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:

  • Post your Tweets on Twitter using your own software
  • Easy browsing through your own Tweets or the Tweets on any other time-line
  • Easy browsing through friends and followers
  • Integrated OAuth (Open Authorization) supports both both Client and Web use cases
  • Authenticate users in only two steps
  • Access all of the functions that are publicly available on the Twittter HTTP interface
  • Proved an interface to send custom, OAuth signed, requests to the Twitter HTTP interface

This tutorial describes how the Twitter Toolkit can be integrated into ASP projects.

Step 1: Download and install the Twitter Toolkit

Download the Twitter Toolkit from the ActiveXperts web site and start the installation. The installation guides you through the installation process.  Download now »

Step 2: Create a new Web Site

First, create a new directory on the IIS Server's file system. This directory will hold the ASP later on.

From the 'Start menu', click on 'Administrative Tools' and click on 'Internet Information Services (IIS) Manager'. Right-click on the 'Web Sites' container and choose 'New->Web Site':

SMS ASP

(Click on the picture to enlarge)

The 'Web Site Creation Wizard' is shown, guiding you through the process of creating a new web site. Provide all necessary information:

  • Description - a friendly description of the new site;
  • IP / Port / Host Header - choose your preferred way to distinguish between other web sites on the server;
  • Path - select the directory that will store the ASP file(s);
  • Web Site Access Permissions - in the Web Site Access Permissions dialog, enable 'Read' and 'Run scripts (such as ASP)';

You're now able to write an ASP script to send and receive SMS messages using the Twitter Toolkit.

Step 3: Create the Twitter Toolkit objects in ASP

Create a new ASP script called DEFAULT.ASP in the directory that was created in Step2, using your favorite editor. On top of the ASP code, insert the following lines to declare and create the SMS objects:

<object runat=server progid="ActiveXperts.Twitter" id=objTwitter ></object>

Insert the following lines to declare and create the Twitter object:

Step 4: Test a small piece of ASP

Now, test if your new web site is working well with the Twitter Toolkit using your browser. If you are using Microsoft Internet Explorer, it is recommended to disable friendly error message because this default setting doesn't show any ASP error message, making it hard to debug if there are any problems:

  • Choose' Internet Options' from the 'Tools' menu;
  • Select the 'Advanced' tab;
  • In the 'Browsing' folder, de-select the 'Show friendly HTTP error messages' option;
  • Click 'OK' to close the dialog.

Step 5: Tweet a message

The following code shows how to tweet a message using ASP

<object runat="server" progid="ActiveXperts.Twitter" id="objTwitter"> </object>

<html>

<head>
<title>ActiveXperts Twitter Sample</title>
<style>
   .clbody {
   font-family:Verdana, Arial, Helvetica, sans-serif;
   font-size:9pt;
   font-weight:normal;
}
.clfooter {
   font-family:Verdana;
   font-size:7pt;
   font-weight:normal;
}
h1, .h1 {
   width:100%;
   font-family:Verdana, Arial, Helvetica, sans-serif;
   font-size:18px;
   font-weight:bold;
}
hr, .hr {
   color:#b0b0b0;
}
</style>
</head>

<body class="clbody">
<h1>ActiveXperts Twitter Sample</h1>
<hr size="1">
<div style="width:800px">
In this sample you need to have a consumer key and an access key. 
</div>
<hr size="1">
<br>

<%
  Dim numLastError, strLastError

  numLastError = 0
  strLastError = ""

  If Request( "CTL_TWEET" ) <> "" Then
    objTwitter.LoadConsumerKey Request( "CTL_CONSUMERKEYFILE" ) 
    numLastError =  objTwitter.LastError

    If numLastError = 0 Then
      objTwitter.LoadAccesskey Request( "CTL_ACCESSKEYFILE" ) 
    End If

    If( numLastError = 0 ) then
      objTwitter.Tweet Request( "CTL_MESSAGE" ) 
    End If

    strLastError =  objTwitter.GetErrorDescription( numLastError )
  End If
%>

<form action="default.asp" method="post">
<table class ="clbody" width="800">
   <tr>
      <td width="200" valign="top">ActiveXperts Twitter Toolkit:</td>
      <td width="600" valign="top">Build: <% = objTwitter.Build %>;</td>
   </tr>
   <tr>
      <td></td>
      <td></td>
   </tr>
   <tr>
      <td valign="top">Consumer Key:</td>
      <td valign="top"><input size="80" type="text" name="CTL_CONSUMERKEYFILE" value=""></td>
   </tr>
   <tr>
      <td valign="top">Access Key:</td>
      <td valign="top"><input size="80" type="text" name="CTL_ACCESSKEYFILE" value=""></td>
   </tr>

   <tr>
      <td valign="top">Tweet:</td>
      <td valign="top"><input size="80" type="text" name="CTL_MESSAGE" value=""></td>
   </tr>
   <tr>
      <td valign="top"> xyz</td>
      <td valign="top"><input size="80" type="submit" value="Tweet" name="CTL_TWEET"></td>
   </tr>
   <tr>
      <td valign="top"> </td>
      <td valign="top"> </td>
   </tr>
      <tr>
      <td valign="top">Result code:</td>
      <td valign="top"><b><% = numLastError %>: <% = strLastError%></b></td>
   </tr>
      
</table>
<br>
<br>
</form>

</body>
</html>

Samples

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


Support Operating Systems

The Twitter Toolkit can be used by any of the following operating systems:

  • Windows XP, x86 (32-bit) and x64 (64-bit)
  • Windows 2003, x86 (32-bit) and x64 (64-bit)
  • Windows 2008, x86 (32-bit) and x64 (64-bit)
  • Windows Vista, x86 (32-bit) and x64 (64-bit)
  • Windows 7, x86 (32-bit) and x64 (64-bit)