Use this PHP fucntion to create Bitly Short Link using PHP

 

 

In Additional to this if  you want to create Short link using php function :-

<?php
function createShortLink($long_url)
{
$bitly_login = "bitlydemo";
$bitly_api   = "R_0da49e0a9118ff35f52f629d2d71bf07";
$long_url = urlencode($long_url);
$bitly_response = json_decode(file_get_contents("http://api.bit.ly/v3/shorten?login={$bitly_login}&apiKey={$bitly_api}&longUrl={$long_url}&format=json"));
$short_url = $bitly_response->data->url;
return $short_url;
}
?>

if you want to get lng url from this use this function

<?php
define('LOGIN', 'bitlydemo');
define('API_KEY', 'R_0da49e0a9118ff35f52f629d2d71bf07');
define('END_POINT', 'http://api.bit.ly/v3');
function getLongUrl($shortUrl)
	{
		$query = http_build_query(
			array(
				'login' => LOGIN,
				'apiKey' => API_KEY,
				'shortUrl' => $shortUrl,
				'format' => 'txt'
			)
		);
		return file_get_contents(sprintf('%s/%s?%s', END_POINT, 'expand', $query));
	}
?>