Introducción a Zend Framework

 Aprendiendo Zend Framework

Apéndice

 Referencia de Zend Framework


  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Traducción al 26.9% - Actualizado el 2011-11-16 - Revisión 24249 - Versión ZF 1.11.x

    63.26. Zend_Service_ShortUrl

    63.26.1. Overview

    URL shorteners have exploded in popularity in the last several years, in large part due to the social nature of the web and the desire to share links. Zend_Service_ShortUrl provides an API for accessing a number of different URL shortener services, with the ability to both create short URLs as well as retrieve the original URL.

    Adapters provided include:

    • Zend_Service_ShortUrl_JdemCz, which accesses the jdem.cz service.

    • Zend_Service_ShortUrl_TinyUrlCom, which accesses the tinyurl.com service.

    • Zend_Service_ShortUrl_MetamarkNet, which accesses the metamark.net service.

    • Zend_Service_ShortUrl_IsGd, which accesses the is.gd service.

    63.26.2. Quick Start

    Using one of the URL shortener services is straightforward. Each URL shortener follows a simple interface that defines two methods: shorten() and unshorten(). Instantiate the class, and call the appropriate method.

    $tinyurl = new Zend_Service_ShortUrl_TinyUrlCom();

    // Shorten a URL:
    $short $tinyurl->shorten('http://framework.zend.com/'); // http://tinyurl.com/rxtuq

    // Inflate or unshorten a short URL:
    $long  $tinyurl->unshorten('http://tinyurl.com/rxtuq'); // http://framework.zend.com/

    63.26.3. Available Methods

    shorten($url);

    Takes the given $url and passes it to the service in order to obtain a shortened URL.

    If the provided $url is invalid, an exception will be raised.

    unshorten($shortenedUrl);

    Takes the provided $shortenedUrl and passes it to the service in order to obtain the original URL.

    If the provided $shortenedUrl is invalid, an exception will be raised.

    setHttpClient(Zend_Http_Client $httpClient);

    Use this method to set the HTTP client used for communicating with the service.

    getHttpClient();

    Use this method to access the HTTP client attached to the service. By default, this will lazy-load an instance of Zend_Http_Client if no client is yet attached.

    digg delicious meneame google twitter technorati facebook

    Comentarios

    Loading...