Posted by & filed under Programming.

Needed a quick and easy way to create a bit.ly URL for another site of mine. Google came through for me.

David Walsh posted a short PHP function on his site that takes your bit.ly login, API key, and the URL to shorten and returns a nice, short bit.ly link.

Link: http://davidwalsh.name/bitly-php

Just put the function into your file and…

$shortURL = make_bitly_url($longURL, $bitlyLogin, $bitlyAPIKey);

And that’s it. A new bit.ly URL is created and stored in $shortURL for you.

I started using this on my @DailyFont Twitter feed today to post fonts as they’re added to the site and after a couple of test Tweets it seems to be working without a hitch.

One Response to “bit.ly and PHP”

  1. Ryan

    About 45 minutes ago was the first time the cron job ran and it worked without a hitch. Picked the font for today, got a bit.ly link to it, and Tweeted it.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *