Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
20 lines (14 sloc) 658 Bytes
<?php
//the long url posted by the map webpage
$url = urlencode(trim($_GET["url"]));
//You have to create an account on bit.ly and modify the username and API key.
$api_user = "username";
$api_key = "api_key";
//send it to the bitly shorten webservice
$ch = curl_init ("http://api.j.mp/v3/shorten?login=$api_user&apiKey=$api_key&longUrl=$url&format=json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//the response is a JSON object, send it to the webpage with a callback
echo $_GET['jsoncallback'] . '(' . curl_exec($ch) . ');';
// close cURL resource, and free up system resources
curl_close($ch);
?>