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

Quicklinks


How to use ActiveXperts Twitter Toolkit with ASP .NET (C#)

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.NET CSharp C# projects.

Prerequisites

You must install and configure Internet Information Services (IIS) before using the ActiveXperts Twitter Toolkit Toolkit with ASP .NET If you don't have IIS installed, use the following steps:

  • From the Control Panel, click 'Add/Remove Programs'. Select the 'Add/Remove Windows Components' icon from the left pane, then select 'Application Server' and click on 'Details'. You can now select both 'ASP .NET' and 'Internet Information Services (IIS)'. Click 'OK' to continue installation;

  • Make sure that ASP .NET is allowed on the web server:

    ASP.NET Visual Csharp

    (Click on the picture to enlarge)

Step 1: Download and install ActiveXperts 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 ASP .NET C# Project

Launch Microsoft Visual Studio (for instance 'Microsoft Visual Studio 2005') from the Start menu. Choose 'New' from the 'File' menu and click on 'Web Site'. In the 'Web Site' dialog, select ASP .NET Web Site. 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):

ASP.NET Visual C#

(Click on the picture to enlarge)

Step 3: Refer to the ActiveXperts Twitter Toolkit Library and create the objects

Now that a new project has been created, you must add a reference to the ActiveXperts Twitter Toolkit toolkit in the project to be able to use the ActiveXperts 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 'ActiveXperts Twitter Toolkit 2.2 Type Library' as shown in the following picture:

ASP.NET Visual C sharp

(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 ActiveXperts Twitter Toolkit namespace:

using twitter-componentLib;

In your Main function, declare and create the following object:

public Twitter m_objTwitter;

m_objTwitter = new Twitter();

Step 4: Tweet a message

The following code shows how to tweet a message using ASP .NET VB.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using twitter-componentLib;

namespace twittercsharp
{
  public partial class _Default : System.Web.UI.Page
  {
    public Twitter objTwitter = new Twitter();

    protected void Page_Load(object sender, EventArgs e)
    {
      if( ! IsPostBack )
      {
        string strConsumerKeyFile = "", strAccessKeyFile = "";

        ctlInfo.Text = "Build: " + objTwitter.Build + "; Module: " + objTwitter.Module;

        ctlConsumerKeyFile.Text = "c:\\consumer.key";
        ctlAccessKeyFile.Text = "c:\\access.key";
      }
    }

    protected void ctlTweet_Click(object sender, EventArgs e)
    {
      objTwitter.Clear();
      objTwitter.LoadConsumerKey(ctlConsumerKeyFile.Text);
      if (objTwitter.LastError == 0)
      {
        objTwitter.LoadAccessKey(ctlAccessKeyFile.Text);
      }
      if (objTwitter.LastError == 0)
      {
        objTwitter.Tweet(ctlMessage.Text);
      }

      ctlResult.Text = objTwitter.LastError 
    }
  }
}

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)