Get a Twitter Account’s Registration Date via Snow Leopard Service

Creating services in Snow Leopard is all the rage lately. So is Twitter. This tutorial brings both of them together and should serve as a fine example of just how slick and useful services in Snow Leopard can be.

Step 1: Write a script to grab a twitter account’s registration date

I recently became curious about how long some of the people I follow have been on Twitter. Using this info from Twitter’s API documentation, I made the following curl command to grab info on my own account:

curl -s

This returns a bunch of info in XML format:

<?xml version="1.0" encoding="UTF-8"?>
  <name>Peter Bukowinski</name>
  <description>IT geek, father of two, California ex-patriate, frequent flier</description>
  <created_at>Tue May 20 14:45:16 +0000 2008</created_at>
  <time_zone>Eastern Time (US &amp; Canada)</time_zone>
    <created_at>Sat Sep 12 01:38:58 +0000 2009</created_at>
    <text>@hotdogsladies That's the best description I've heard yet. You must be between Durant and Dwight.</text>
    <source>&lt;a href=&quot;; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</source>

The line that contains the info I want is the first <created_at> line, showing that I registered on May 20, 2008 — a relative late-comer, I know…. If you’ve visited this blog before, you’re likely aware of my love for awk. I’ll pipe curl’s output to awk to isolate the data I want:

curl -s | \
awk '/^  <created_at>/{sub("</created_at>","");print $2" "$3", "$6}'

This outputs “May 20, 2008” — great! Now let’s build a service with Automator that will allow us to right-click on any Twitter account name and have a dialog pop up with that account’s registration date.

Step 2: Build a service with Automator

Open up, found in your Applications folder. You’ll be presented with some workflow template choices. Double-click the Service item.


Note that the Service template has an input section already at the top.


Leave the options set to defaults. Now type “shell” into the search box in the upper left area of the window and then drag the Run Shell Script action into the workflow area.


Leave the Shell option set to /bin/bash, but change the Pass input option to as arguments. Replace the placeholder data in the script area with the following:

curl -s$1 | \
awk '/^  <created_at>/{sub("</created_at>","");print $2" "$3", "$6}'

Note that I used “$1” instead of an account name. In bash, the $1 variable in a script contains the first argument passed to the script. In this case, we’re passing whatever text we selected or right-clicked on to the script. Now we need a way to display the text on screen. AppleScript is perfect for this, so type “script” into the search box and then drag the Run AppleScript action to the bottom of the workflow area.


Now, replace the contents of the script area with this:

on run {regDate}
    tell application "Finder"
    display dialog "Twitter account registered on " & regdate & "." buttons{"OK"}
    end tell
end run

The first line imports the info from the previous step to a variable named regDate. Then we’re telling the Finder to display a dialog with the text “Twitter account registered on [regDate].” Simple, right? Now click the hammer icon in the Applescript action to compile the script and check for errors. You’ll see the text change font and colors if all went well.


Step 3: Save and test the service

You’re done building the service, so save it. I named mine Get Twit Age, but feel free to name yours however you want. Snow Leopard’s Automator will automatically save it in the correct location for use. In order to test this service, you need to be running a Cocoa application1 that has selectable text. Since we’re talking about Twitter, here, may I suggest Safari? Open the page of a Twitter user’s account ( that you’d like to know the age of. Right-click on their account name and then select Get Twit Age (or whatever you called your service) near the bottom of the contextual menu. In a few moments, you should see a dialog box containing the account’s registration date.


And there you have it. If you happen to right-click on some text that doesn’t correspond to a twitter account, you won’t get an error but the dialog will simply display “Twitter account registered on .”

Hopefully, this tutorial gave you an idea of how easy it is to combine snippets of code to create a useful service. Now get out there and automate!

  1. John Gruber points out in his article about iTunes 9 and Cocoa that while all apps can access system-wide services via the Services item in the Application menu, only Cocoa-based apps can access contextual services.

2 thoughts on “Get a Twitter Account’s Registration Date via Snow Leopard Service

  1. 6/27/11





    curl -s

    didn’t work for me, at some unknown date seem like someone opened an account on my name…

    the account has never been used,

    name details look ‘fishy’ to me…

    can not reset password, emails do not match…

    getting the date i could check my dairy for clues…

    Web Results

    Your search – curl -s – did not match any documents.


    Make sure all words are spelled correctly.
    Try different keywords.
    Try more general keywords.

Comments are closed.