Zend_Service_ShortUrl.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.service.short-url">
  4. <title>Zend_Service_ShortUrl</title>
  5. <sect2 id="zend.service.short-url.intro">
  6. <title>Overview</title>
  7. <para>
  8. URL shorteners have exploded in popularity in the last several years, in large part due
  9. to the social nature of the web and the desire to share links.
  10. <classname>Zend_Service_ShortUrl</classname> provides an API for accessing a number of
  11. different URL shortener services, with the ability to both create short URLs as well as
  12. retrieve the original URL.
  13. </para>
  14. <para>
  15. Adapters provided include:
  16. </para>
  17. <itemizedlist>
  18. <listitem>
  19. <para>
  20. <classname>Zend_Service_ShortUrl_JdemCz</classname>, which accesses the <ulink
  21. url="http://jdem.cz/">jdem.cz</ulink> service.
  22. </para>
  23. </listitem>
  24. <listitem>
  25. <para>
  26. <classname>Zend_Service_ShortUrl_TinyUrlCom</classname>, which accesses the <ulink
  27. url="http://tinyurl.com">tinyurl.com</ulink> service.
  28. </para>
  29. </listitem>
  30. </itemizedlist>
  31. </sect2>
  32. <sect2 id="zend.service.short-url.quick-start">
  33. <title>Quick Start</title>
  34. <para>
  35. Using one of the URL shortener services is straightforward. Each URL shortener follows a
  36. simple interface that defines two methods: <methodname>shorten()</methodname> and
  37. <methodname>unshorten()</methodname>. Instantiate the class, and call the appropriate
  38. method.
  39. </para>
  40. <programlisting language="php"><![CDATA[
  41. $tinyurl = new Zend_Service_ShortUrl_TinyUrlCom();
  42. // Shorten a URL:
  43. $short = $tinyurl->shorten('http://framework.zend.com/'); // http://tinyurl.com/rxtuq
  44. // Inflate or unshorten a short URL:
  45. $long = $tinyurl->unshorten('http://tinyurl.com/rxtuq'); // http://framework.zend.com/
  46. ]]></programlisting>
  47. </sect2>
  48. <sect2 id="zend.service.short-url.methods">
  49. <title>Available Methods</title>
  50. <variablelist>
  51. <varlistentry id="zend.service.short-url.methods.shorten">
  52. <term>
  53. <methodsynopsis>
  54. <methodname>shorten</methodname>
  55. <methodparam>
  56. <funcparams>$url</funcparams>
  57. </methodparam>
  58. </methodsynopsis>
  59. </term>
  60. <listitem>
  61. <para>
  62. Takes the given <varname>$url</varname> and passes it to the service in
  63. order to obtain a shortened URL.
  64. </para>
  65. <para>
  66. If the provided <varname>$url</varname> is invalid, an exception will be
  67. raised.
  68. </para>
  69. </listitem>
  70. </varlistentry>
  71. <varlistentry id="zend.service.short-url.methods.unshorten">
  72. <term>
  73. <methodsynopsis>
  74. <methodname>unshorten</methodname>
  75. <methodparam>
  76. <funcparams>$shortenedUrl</funcparams>
  77. </methodparam>
  78. </methodsynopsis>
  79. </term>
  80. <listitem>
  81. <para>
  82. Takes the provided <varname>$shortenedUrl</varname> and passes it to the
  83. service in order to obtain the original URL.
  84. </para>
  85. <para>
  86. If the provided <varname>$shortenedUrl</varname> is invalid, an exception
  87. will be raised.
  88. </para>
  89. </listitem>
  90. </varlistentry>
  91. <varlistentry id="zend.service.short-url.methods.set-http-client">
  92. <term>
  93. <methodsynopsis>
  94. <methodname>setHttpClient</methodname>
  95. <methodparam>
  96. <funcparams>Zend_Http_Client $httpClient</funcparams>
  97. </methodparam>
  98. </methodsynopsis>
  99. </term>
  100. <listitem>
  101. <para>
  102. Use this method to set the HTTP client used for communicating with the
  103. service.
  104. </para>
  105. </listitem>
  106. </varlistentry>
  107. <varlistentry id="zend.service.short-url.methods.get-http-client">
  108. <term>
  109. <methodsynopsis>
  110. <methodname>getHttpClient</methodname>
  111. <methodparam>
  112. <funcparams></funcparams>
  113. </methodparam>
  114. </methodsynopsis>
  115. </term>
  116. <listitem>
  117. <para>
  118. Use this method to access the HTTP client attached to the service. By
  119. default, this will lazy-load an instance of
  120. <classname>Zend_Http_Client</classname> if no client is yet attached.
  121. </para>
  122. </listitem>
  123. </varlistentry>
  124. </variablelist>
  125. </sect2>
  126. </sect1>