Bit.ly API command line tool
I’ve knocked up a really simple command line tool for interacting with the bit.ly API.
It’s simple because:
- The output is currently pretty raw
- The bit.ly API doesn’t actually do very much
Requires PHP >= 5.2.x + json extension
INSTALL
Ensure you have a PHP binary at /usr/bin/php and check the version is suitable
$ which php /usr/bin/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 bitly-0-1-1/ bitly-0-1-1/bitly bitly-0-1-1/README $ cd bitly-0-1-1 $ chmod u+x bitly
Configure it for your bit.ly 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
USAGE
Run the help command to see available commands
$ bitly -h
Example, to shorten a URL:
$ bitly shorten http://web.2point1.com
CHANGELOG
Version 0.1
First release
Version 0.1.1
Added –version switch
Added history=1 into shorten method (ensures it actually goes into your bit.ly history)
Added optional keyword for custom URLs to shorten method
Great! Thanks!
It seems to work, but if you want to use it in a shell script how do you pass the short_url to a shell variable?
Thanks
Doesn’t work for me. Can you post a public source repo (github?) so I can send you a patch?
Even after adding my auth at the top, I get the error:
Array
(
[errorCode] => 500
[errorMessage] => MISSING_ARG_LOGIN
[results] =>
[statusCode] =>
)
I get the same error
Guys, as you can see this little project is two years old and not maintained.
I shall try to find some time to fix, and will add to Github.
@tim
Definitely! It’s a great little thing, it would be cool to have it working and maintained
Definitely! It’s a great little tool, would be cool to have it working and maintained!