Shorten URLs with Zend Framework and

This function uses version 3.0 of the API. You’ll need to register for an account with them if you don’t already have one. Then you can retrieve your API key and begin using it immediately.

function bitlyShorten($url)
	$client = new Zend_Http_Client('');

		'longUrl' => $url,
		'login' => 'xyz',
		'apiKey' => 'xyz'

	$response = $client->request();

		$response = Zend_Json::decode($response->getBody());
		if($response['status_code'] == 200)
			return $response['data']['url'];
	return (false);


$myLongUrl = '';
$myShortUrl = bitlyShorten($myLongUrl);

Leave a Reply

Your email address will not be published.