Short url bit.ly PHP

<?php
public function getBitlyUrl($url)
{

$version=”version=2.0.1”;
$login=”phpcodez”; // Replace with your login
$API=”phpcodez”;// Replace with your API
$bitly = ‘http://api.bit.ly/shorten?”.$version.”&longUrl=’.urlencode($url).’&login=”.$login.”&apiKey=”.$API.”&format=xml’;
$response = file_get_contents($bitly);
$xml = simplexml_load_string($response);
return ‘http://bit.ly/’.$xml->results->nodeKeyVal->hash;

}

?>

Share