News Feed
Jobs Feed
Sections




News Archive
Lorna Mitchell's Blog:
July 28, 2011 @ 12:03:02

Lorna Mitchell has a quick post to her blog today showing how you can use a simple curl call from PHP to shorten urls with bit.ly and pull back the result.

I've been looking around for a really simple API that would be a nice place to get started using web services from PHP - and I realised that bit.ly actually fits the bill really well. They have straightforward api docs on google code, and it's also a pretty simple function!

Her code is about three lines consisting of a curl_init call to the bit.ly server with the URL, a curl_setopt to tell it to return the information and a curl_exec to execute. The result is a JSON string easily decoded with a "url" parameter containing the newly minted short URL. She also briefly mentions some of the other features of the bit.ly API including reverse translation and bundling of links.

0 comments voice your opinion now!
bitly url shortening api curl example


blog comments powered by Disqus

Similar Posts

Evert Pot's Blog: PHP Quicksearch in Firefox

Andrew Podner: PHP 5.5 Preview: New Password Hashing API

OpenSky Blog: Inheritance in PHP, or why you want to use an Interface or an Abstract class...

Ilia Alshanetsky's Blog: MySQL Binaries and cURL/http extensions in PHP

PHPMaster.com: Spooky Scary PHP


Community Events











Don't see your event here?
Let us know!


conference code community introduction functional development example opinion release composer tool language podcast testing object unittest series interview zendframework2 framework

All content copyright, 2013 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework