API command line tool

I’ve knocked up a really simple command line tool for interacting with the API.

It’s simple because:

  1. The output is currently pretty raw
  2. The API doesn’t actually do very much

ยป Download version 0.1.1

Requires PHP >= 5.2.x + json extension


Ensure you have a PHP binary at /usr/bin/php and check the version is suitable

$ which php
$ /usr/bin/php --version
PHP 5.2.x (cli) (built: ..........)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

Unzip the download, and ensure it’s executable:

$ tar -xvzf bitly-0-1-1.tar.gz
$ cd bitly-0-1-1
$ chmod u+x bitly

Configure it for your account, by redefining two constants at the top of the file. They look like this:

define( 'BITLY_USER', '' );
define( 'BITLY_PASSWORD', '' );

Optionally move the executable somewhere useful:

$ mkdir -p ~/bin
$ mv -v bitly ~/bin
bitly ->/home/xxxx/bin/bitly


Run the help command to see available commands

$ bitly -h

Example, to shorten a URL:

$ bitly shorten


Version 0.1
First release

Version 0.1.1
Added –version switch
Added history=1 into shorten method (ensures it actually goes into your history)
Added optional keyword for custom URLs to shorten method

See also API documentation