Zend_Service_Twitter_Search.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.service.twitter.search">
  4. <title>Zend_Service_Twitter_Search</title>
  5. <sect3 id="zend.service.twitter.search.introduction">
  6. <title>Introduction</title>
  7. <para>
  8. <classname>Zend_Service_Twitter_Search</classname> provides a client for the
  9. <ulink url="http://apiwiki.twitter.com/Search+API+Documentation">Twitter Search
  10. <acronym>API</acronym></ulink>. The Twitter Search service is use to search Twitter.
  11. Currently, it only returns data in Atom or <acronym>JSON</acronym> format, but a full
  12. <acronym>REST</acronym> service is in the future, which will support
  13. <acronym>XML</acronym> responses.
  14. </para>
  15. </sect3>
  16. <sect3 id="zend.service.twitter.search.trends">
  17. <title>Twitter Trends</title>
  18. <para>
  19. Returns the top ten queries that are currently trending on Twitter. The response
  20. includes the time of the request, the name of each trending topic, and the url to the
  21. Twitter Search results page for that topic. Currently the search <acronym>API</acronym>
  22. for trends only supports a <acronym>JSON</acronym> return so the function returns
  23. an array.
  24. </para>
  25. <programlisting language="php"><![CDATA[
  26. $twitterSearch = new Zend_Service_Twitter_Search();
  27. $twitterTrends = $twitterSearch->trends();
  28. foreach ($twitterTrends as $trend) {
  29. print $trend['name'] . ' - ' . $trend['url'] . PHP_EOL
  30. }
  31. ]]></programlisting>
  32. <para>
  33. The return array has two values in it:
  34. </para>
  35. <itemizedlist>
  36. <listitem>
  37. <para>
  38. <code>name</code> is the name of trend.
  39. </para>
  40. </listitem>
  41. <listitem>
  42. <para>
  43. <code>url</code> is the <acronym>URL</acronym> to see the tweets for
  44. that trend.
  45. </para>
  46. </listitem>
  47. </itemizedlist>
  48. </sect3>
  49. <sect3 id="zend.service.twitter.search.search">
  50. <title>Searching Twitter</title>
  51. <para>
  52. Using the search method returns tweets that match a specific query. There are a number
  53. of <ulink url="http://search.twitter.com/operators">Search Operators</ulink> that you
  54. can use to query with.
  55. </para>
  56. <para>
  57. The search method can accept six different optional <acronym>URL</acronym> parameters
  58. passed in as an array:
  59. </para>
  60. <itemizedlist>
  61. <listitem>
  62. <para>
  63. <code>lang</code> restricts the tweets to a given language. <code>lang</code>
  64. must be given by an
  65. <ulink url="http://en.wikipedia.org/wiki/ISO_639-1">ISO 639-1 code</ulink>.
  66. </para>
  67. </listitem>
  68. <listitem>
  69. <para>
  70. <code>rpp</code> is the number of tweets to return per page, up to a maximum
  71. of 100.
  72. </para>
  73. </listitem>
  74. <listitem>
  75. <para>
  76. <code>page</code> specifies the page number to return, up to a maximum of
  77. roughly 1500 results (based on rpp * page).
  78. </para>
  79. </listitem>
  80. <listitem>
  81. <para>
  82. <code>since_id</code> returns tweets with status IDs greater than the given ID.
  83. </para>
  84. </listitem>
  85. <listitem>
  86. <para>
  87. <code>show_user</code> specifies whether to add "&gt;user&lt;:" to the
  88. beginning of the tweet. This is useful for readers that do not display Atom's
  89. author field. The default is "<constant>FALSE</constant>".
  90. </para>
  91. </listitem>
  92. <listitem>
  93. <para>
  94. <code>geocode</code> returns tweets by users located within a given radius of
  95. the given latitude/longitude, where the user's location is taken from their
  96. Twitter profile. The parameter value is specified by
  97. "latitude,longitude,radius", where radius units must be specified as either
  98. "mi" (miles) or "km" (kilometers).
  99. </para>
  100. </listitem>
  101. </itemizedlist>
  102. <example id="zend.service.twitter.search.search.json">
  103. <title>JSON Search Example</title>
  104. <para>
  105. The following code sample will return an array with the search results.
  106. </para>
  107. <programlisting language="php"><![CDATA[
  108. $twitterSearch = new Zend_Service_Twitter_Search('json');
  109. $searchResults = $twitterSearch->search('zend', array('lang' => 'en'));
  110. ]]></programlisting>
  111. </example>
  112. <example id="zend.service.twitter.search.search.atom">
  113. <title>ATOM Search Example</title>
  114. <para>
  115. The following code sample will return a <classname>Zend_Feed_Atom</classname>
  116. object.
  117. </para>
  118. <programlisting language="php"><![CDATA[
  119. $twitterSearch = new Zend_Service_Twitter_Search('atom');
  120. $searchResults = $twitterSearch->search('zend', array('lang' => 'en'));
  121. ]]></programlisting>
  122. </example>
  123. </sect3>
  124. <sect3 id="zend.service.twitter.search.accessors">
  125. <title>Zend-specific Accessor Methods</title>
  126. <para>
  127. While the Twitter Search <acronym>API</acronym> only specifies two methods,
  128. <classname>Zend_Service_Twitter_Search</classname> has additional methods that may be
  129. used for retrieving and modifying internal properties.
  130. </para>
  131. <itemizedlist>
  132. <listitem>
  133. <para>
  134. <methodname>getResponseType()</methodname> and
  135. <methodname>setResponseType()</methodname>
  136. allow you to retrieve and modify the response type of the search between
  137. <acronym>JSON</acronym> and Atom.
  138. </para>
  139. </listitem>
  140. </itemizedlist>
  141. </sect3>
  142. </sect2>
  143. <!--
  144. vim:se ts=4 sw=4 et:
  145. -->