Tips And Resources For Software Consultants

Displaying Your FeedBurner Subscriber Count Anywhere – PHP Coding Tutorial


If you are a serious blogger (and I’m sure you are), you probably track your RSS subscribers with FeedBurner. If you don’t, you should be. One thing that has always bugged me about FeedBurner is if you ever wanted to display the number of subscribers on your blog, you were stuck using their image. The image looks like this:

I’m sure you have seen this logo everywhere. Well, not too many people know it, but FeedBurner actually has a very simple API that allows you to just get the subscriber count so you can display it however you would like.

So rather than being limited to this boring icon, you can display your live subscriber count anywhere on your blog. If you are feeling adventurous, you could even super impose it on to your own custom image using the GD library (tutorial to come if sufficient interest, post in the comments if you would like to see it).

Let’s get started…

1. Activate the Awareness API Inside Of Feedburner

Log in to FeedBurner. Click the Publicize tab and the click Awareness API. Finally, click Activate. The service is now enabled.


2. Write The PHP Code To Interface With FeedBurner

There is a lot of data that you could potentially get from FeedBurner, but the code below will just show you how to get your subscriber count.

All you need to do is make a simple GET request using CURL to the URL . Of course replacing brandontreb with your feed’s name.

<code class=’php’><?php

$url    = "";
$ch     = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch); 
if ($data) {
    echo $data;
    preg_match(‘/circulation=\"([0-9]+)\"/’,$data, $matches);
    if ($matches[1] != 0) {
        $subscriberCount = $matches[1];

echo "Join the other $subscriberCount people and subscriber to my RSS feed."


This code is pretty straight forward with a little trickiness to parse the XML. We first make a CURL connection to the URL. Just replace brandontreb with the title of your RSS feed inside of FeedBurner.

Next we print the data. Note: You won’t see the data in your browser unless you do a view source. Since it is XML, your browser will treat it like HTML and not display it. So, we do a preg_match for the element circulation and get it’s value. (Pretty sick right?). The value of our subscriber count will be at index 1 of the matches array.

Then, we just print the subscriber count and voila!

Now, you are no longer a slave to that generic FeedBurner subscriber count icon. Be sure to check out their API for other cool things that you can do with their web services. If you have any questions, feel free to leave them in the comments section of this post. Happy Coding!

Easily Create And Manage SQLite Databases With A Firefox Plugin

If you are doing any Mac, iPhone, HTML5, etc… developement, you have probably had the need for an sqlite database. So, you fire up your Terminal and start manully typing commands to do CREATEs and INSERTs.

You soon realize that this sucks and wish you had something like (shudders) PHPMyAdmin to manage your database. Well, now you do and it’s actually a lot less hiddeous than PHPMyAdmin.

Using the SQLite Manager plugin for Firefox, you can quickly CREATE, MODIFY, and DELETE sqlite databases visually. It’s very simple to use and makes the task of database creation a lot less painful.


Here the description from the plugin site.

Manage any SQLite database on your computer. An intuitive heirarchical tree showing database objects. Helpful dialogs to manage tables, indexes, views and triggers. You can browse and search the tables, as well as add, edit, delete and duplicate the records. Facility to execute any sql query. The views can be searched too. A dropdown menu helps with the sql syntax thus making writing sql easier. Easy access to common operations through menu, toolbars, buttons and context-menu. Export tables/views/database in csv/xml/sql format. Import from csv/xml/sql (both UTF-8 and UTF-16). Possible to execute multiple sql statements in Execute tab. You can save the queries. Support for ADS on Windows.

You can download the SQLite Manager plugin for Firefox here.

XCode Shortcut Cheat Sheet

Xcode ShortcutsThrough my travels through the internets, I have stumbled upon this amazing reference. It’s a complete set of XCode shortcut commands. Learning some of these commands has drastically improved my efficiency when developing in XCode.

As a big fan of not using the mouse (yes I’m and Emacs guy), this is invaluable. Download the full size image here. Enjoy!

Creating A Twitter Client In Objective-C Client Part 2

Creating A Twitter Client For OSX – Part 1

This is part 2 in our series about creating a Twitter client in Objective-C. In case you missed it, here is a link to part 1 of this series.

In the last tutorial I showed you how to retrieve data from Twitter and display the XML in the Console. Today, we will be focusing on sending messages to Twitter via POST. We will be implementing the code to update our Twitter status. So let’s just dig right in.

1. Updating The TwitterRequest Header File

Open up TwitterRequest.h and add the following code (Click the image to enlarge)


We have added two properties. The first isPost will be true when we are calling a method that requires a POST to Twitter. This will be methods such as update_status, follow, etc… Next, the variable requestBody will hold the POST arguments that will be sent to Twitter. These will be things such as status text or friend id.

Finally, we will be adding a method called statuses_update. The reason I named it this is because that is what the method is called in the Twitter API. Like our friends_timeline method, it takes a delegate and selector to call when the request is complete.

Important: I didn’t highlight this in the screenshot but make sure you change theRequest from an NSURLRequest to NSMutableURLRequest. It will give us some additional methods to set up the POST.

2. Updating The Twitter Request Class

Open up **TwitterRequest.m **and add the following code (Click the image to enlarge):


I’ll start by explaining the status_update method. We first set the global isPost property to true. This will tell the request method to make a POST. The next 2 lines set the callback stuff as we did before. The only new line here is setting the requestBody variable. This is just a string that looks like “status=new twitter status”.

The addition to the request **method is what will allow us to POST to Twitter. First, we check if the **isPost property is set. This will be true if request is called from our status_update **method. Next, we call the **setHTTPMethod of the request to POST. This is pretty obvious.

The following line let’s Twitter know the type of data that we are sending to it. Next, we call setHTTPBody to set the body of the request. At some point we will want to URL Encode this string, but that will be for a different tutorial. Just don’t use any special characters such as & and = in your update to Twitter right now. All that is happening on this line is we convert the string to NSData using the **dataUsingEncoding **method of NSString and set it to the HTTPBody.

The last line just sets the Content-Length property to the length of our string. This is needed to correctly do a POST.

3. Calling The statuses_update Method To Update Your Twitter Status

Open up ApplicationDelegate.m and add the following code (click the image to enlarge):


One thing to notice here is I commented out the line to get the friends timeline. This is because having both requests running at the same time with the same request object could cause conflicts. The best way to approch this to create an entirly new TwitterRequest object. I just wanted to keep it short.

This is pretty straight forward. We call the statuses_update method the same way we called the friends_timeline method except pass in the update text. The information received back from Twitter will look something like this:


It’s basically all of your personal profile information.

That’s it for today. If you have any comments or questions, feel free to leave them in the comments of this post or write me on Twitter. You can also download the source for this version below.

Twitter Mac Client Tutorial 2 – Source

Happy Coding!

Installing And Deploying Rails On A Red Hat Server With Passenger

railsI have long been a fan of Ruby on Rails and even jumper on board very early on. The one thing that has held me back from using it in the majority of my projects is the fact that it’s such a pain to configure with Apache.

I know what you are saying… Just switch to a more Rails friendly server. I like and know Apache. Not to mention I also host PHP apps.

With the (re)release of tagacloud, I have recently fell in love with ruby on rails again. So, I looked for a better solution for installation (last time I installed it was 3 years ago) and I stumbled upon Passenger.

It was super easy to use and had my running on Rails in no time.

Deployment is only a matter of uploading application files. No Ruby (on Rails)-specific server configuration required!

Just to give you some background, here are some details about my server.

OS: Linux

Distribution: Red Hat Enterprise Linux Server release 5.3 Hosted At Server Beach

Control Panel: Plesk 8.6

And here are the steps I took to get Ruby on Rails up and running from scratch

1. Install Ruby

<code class=’bash’>yum install ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs</code>

This will do some magic and install Ruby on your system…

2. Download And Install Ruby Gems

Head on over to and download the latest version of Ruby Gems. Here is an example of getting the latest version as of the posting date of this article.

<code class=’bash’>wget</code>

Untar this file…

<code class=’bash’>tar -xvf rubygems-1.3.5.tgz</code>

Navigate to the extracted directory and run the setup script

<code class=’bash’>ruby setup.rb</code>

3. Install Rails

This will install rails. If it asks you about dependencies, just type “Y”

<code class=’bash’>gem install rails</code>

4. Install The Passenger Gem

Now that rails has been installed, we need to install Passenger. The installation process is stupid simple. Passenger can be installed via a Ruby Gem.

<code class=’bash’>gem install passenger</code>

Now, it will do some stuff and and you some questions. At some point in the process, it will check to see if you have all of the dependencies. You most likely will not. Luckily, the geniuses who created Passenger tell you the commands to install all of the dependencies. So just follow the directions and you should be ok.

5. Set Up Passenger For Apache

<code class=’bash’>passenger-install-apache2-module</code>

It will ask you more questions and install everything needed to run Passenger. Pay attention to the stuff spit out at the end of the process. You will take this and paste it into your httpd.conf file. For example, here is the what mine spit out:

<code class=’bash’>LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/ext/apache2/
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4
PassengerRuby /usr/bin/ruby</code>

Your httpd.conf file is probably located at /etc/httpd/conf/httpd.conf

You should now be good to go! Navigate to one of your vhosts folder (ex: tagacloud/httpdocs/) and create (or copy) a rails application.

<code class=’bash’>rails someRailsApp</code>

Then set permissions…

<code class=’bash’>chmod -R 755 someRailsApp</code>

And then a miracle happens… and viola! You (should) have a fully functional up and running. Navigate to to see your app in action.

If you have any comments or questions, feel free to leave them in the comments section of this post.