Skip to content and PHP

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

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


Just put the function into your file and…

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

And that’s it. A new 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.

Published inProgramming

One Comment

  1. 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 link to it, and Tweeted it.

Leave a Reply

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