protected function fetch($permlink, $timeout = 10)
	{
		if (!$permlink || !function_exists('curl_init'))
		{
			return;
		}

		$uri = 
			'https://api-ssl.bitly.com/v3/shorten'.
				'?login='.urlencode($this->login).
				'&apiKey='.urlencode($this->apikey).
				'&longUrl='.urlencode($permlink).
				'&format=txt';

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $uri);
		curl_setopt($ch, CURLOPT_FAILONERROR, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
		$bitcode = curl_exec($ch);
		curl_close($ch);

		return $bitcode && strpos($bitcode, 'http') === 0 ? txpspecialchars(trim($bitcode)) : '';
	}
protected function fetch($permlink, $timeout = 10)
	{
		if (!$permlink || !function_exists('curl_init'))
		{
			return;
		}

		$uri = 
			'https://api-ssl.bitly.com/v3/shorten'.
				'?login='.urlencode($this->login).
				'&apiKey='.urlencode($this->apikey).
				'&longUrl='.urlencode($permlink).
				'&format=txt';

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $uri);
		curl_setopt($ch, CURLOPT_FAILONERROR, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
		$bitcode = curl_exec($ch);
		curl_close($ch);

		return $bitcode && strpos($bitcode, 'http') === 0 ? txpspecialchars(trim($bitcode)) : '';
	}
protected function fetch ( $ permlink , $ timeout = 10 ) { if ( ! $ permlink || ! function_exists ( 'curl_init' ) ) { return ; } $ uri = 'https://api-ssl.bitly.com/v3/shorten' . '?login=' . urlencode ( $ this -> login ) . '&apiKey=' . urlencode ( $ this -> apikey ) . '&longUrl=' . urlencode ( $ permlink ) . '&format=txt' ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ uri ) ; curl_setopt ( $ ch , CURLOPT_FAILONERROR , 1 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , $ timeout ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ timeout ) ; $ bitcode = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; return $ bitcode && strpos ( $ bitcode , 'http' ) === 0 ? txpspecialchars ( trim ( $ bitcode ) ) : '' ; }
Fetches a Bitly short URL.

@param  string $permlink The long URL to shorten
@param  int    $timeout  Timeout in seconds
@return string
Fetches a Bitly short URL .