Quantcast
Channel: PHPDeveloper.org
Viewing all articles
Browse latest Browse all 10

Lorna Mitchell's Blog:

$
0
0

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.


Viewing all articles
Browse latest Browse all 10

Trending Articles