View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Service_ShortUrl_Bitly
{zone-data}

{zone-data:proposer-list}
[Christopher Valles|mailto:info@christophervalles.com]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 17 May 2011: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Service_ShortUrl_Bitly is a component to integrate the Bit.ly short url service inside our applications. This component will allow shorting and expanding urls.
{zone-data}

{zone-data:references}
* [Bit.ly API Documentation|http://code.google.com/p/bitly-api/wiki/ApiDocumentation]
{zone-data}

{zone-data:requirements}
* This component *will* allow the developer to create short urls.
* This component *will* allow the developer to expand short urls.
{zone-data}

{zone-data:dependencies}
* Zend_Service_ShortUrl_AbstractShortener
* Zend_Service_ShortUrl_Exception
* Zend_Json
{zone-data}

{zone-data:operation}
The developer has an account with bit.ly
The developer instantiates Zend_Service_ShortUrl_Bitly with their username and API key
The developer uses the component to create short url and/or expand them
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] Supporting Documentation, Use Cases, Class Skeletons, uploaded
* Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
* Milestone 3: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.
{zone-data}

{zone-data:class-list}
* Zend_Service_ShortUrl_Bitly
{zone-data}

{zone-data:use-cases}
||UC-01||
{code}
<?php

$bitlyService = new App_Service_ShortUrl_BitLy($username, $apiKey);
$shortUrl = $bitlyService->shorten('http://google.es');
{code}

||UC-02||
{code}
<?php

$bitlyService = new App_Service_ShortUrl_BitLy($username, $apiKey);
$url = $bitlyService->unshorten('http://bit.ly/1C7Y');
{code}
{zone-data}

{zone-data:skeletons}
{code}
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Service_ShortUrl
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: $
*/

/**
* Bit.ly API implementation
*
* @category Zend
* @package Zend_Service_ShortUrl
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_ShortUrl_BitLy extends Zend_Service_ShortUrl_AbstractShortener
{
/**
* Base URI of the service
*
* @var string
*/
protected $_baseUri = 'http://bit.ly';

/**
* Username used to authenticate the api call
*
* @var string
*/
protected $_username;

/**
* The api key of the service
*
* @var string
*/
protected $_apiKey;

/**
* Store the username and the apiKey
*
* @param string $username
* @param string $apiKey
*/
public function __construct($username, $apiKey) {}

/**
* Create a short url from a full url
*
* @param string $url URL to Shorten
* @throws Zend_Service_ShortUrl_Exception When URL is not valid
* @return string Shorted URL
*/
public function shorten($url) {}

/**
* Expand a short url and return the original url
*
* @param string $shortenedUrl URL to reveal target of
* @throws Zend_Service_ShortUrl_Exception When URL is not valid or is not shortened by this service
* @return string
*/
public function unshorten($shortenedUrl) {}
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>