1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect2 id="zend.service.twitter.search">
4 <title>Zend_Service_Twitter_Search</title>
6 <sect3 id="zend.service.twitter.search.introduction">
7 <title>Introduction</title>
10 <classname>Zend_Service_Twitter_Search</classname> provides a client for the
11 <ulink url="http://apiwiki.twitter.com/Search+API+Documentation">Twitter Search
12 <acronym>API</acronym></ulink>. The Twitter Search service is use to search Twitter.
13 Currently, it only returns data in Atom or <acronym>JSON</acronym> format, but a full
14 <acronym>REST</acronym> service is in the future, which will support
15 <acronym>XML</acronym> responses.
19 <sect3 id="zend.service.twitter.search.trends">
20 <title>Twitter Trends</title>
23 Returns the top ten queries that are currently trending on Twitter. The response
24 includes the time of the request, the name of each trending topic, and the url to the
25 Twitter Search results page for that topic. Currently the search <acronym>API</acronym>
26 for trends only supports a <acronym>JSON</acronym> return so the function returns
30 <programlisting language="php"><![CDATA[
31 $twitterSearch = new Zend_Service_Twitter_Search();
32 $twitterTrends = $twitterSearch->trends();
34 foreach ($twitterTrends as $trend) {
35 print $trend['name'] . ' - ' . $trend['url'] . PHP_EOL
40 The return array has two values in it:
46 <code>name</code> is the name of trend.
52 <code>url</code> is the <acronym>URL</acronym> to see the tweets for
59 <sect3 id="zend.service.twitter.search.search">
60 <title>Searching Twitter</title>
63 Using the search method returns tweets that match a specific query. There are a number
64 of <ulink url="http://search.twitter.com/operators">Search Operators</ulink> that you
65 can use to query with.
69 The search method can accept six different optional <acronym>URL</acronym> parameters
70 passed in as an array:
76 <code>lang</code> restricts the tweets to a given language. <code>lang</code>
78 <ulink url="http://en.wikipedia.org/wiki/ISO_639-1">ISO 639-1 code</ulink>.
84 <code>rpp</code> is the number of tweets to return per page, up to a maximum
91 <code>page</code> specifies the page number to return, up to a maximum of
92 roughly 1500 results (based on rpp * page).
98 <code>since_id</code> returns tweets with status IDs greater than the given ID.
104 <code>show_user</code> specifies whether to add ">user<:" to the
105 beginning of the tweet. This is useful for readers that do not display Atom's
106 author field. The default is "<constant>FALSE</constant>".
112 <code>geocode</code> returns tweets by users located within a given radius of
113 the given latitude/longitude, where the user's location is taken from their
114 Twitter profile. The parameter value is specified by
115 "latitude,longitude,radius", where radius units must be specified as either
116 "mi" (miles) or "km" (kilometers).
121 <example id="zend.service.twitter.search.search.json">
122 <title>JSON Search Example</title>
125 The following code sample will return an array with the search results.
128 <programlisting language="php"><![CDATA[
129 $twitterSearch = new Zend_Service_Twitter_Search('json');
130 $searchResults = $twitterSearch->search('zend', array('lang' => 'en'));
134 <example id="zend.service.twitter.search.search.atom">
135 <title>ATOM Search Example</title>
138 The following code sample will return a <classname>Zend_Feed_Atom</classname>
142 <programlisting language="php"><![CDATA[
143 $twitterSearch = new Zend_Service_Twitter_Search('atom');
144 $searchResults = $twitterSearch->search('zend', array('lang' => 'en'));
149 <sect3 id="zend.service.twitter.search.accessors">
150 <title>Zend-specific Accessor Methods</title>
153 While the Twitter Search <acronym>API</acronym> only specifies two methods,
154 <classname>Zend_Service_Twitter_Search</classname> has additional methods that may be
155 used for retrieving and modifying internal properties.
161 <methodname>getResponseType()</methodname> and
162 <methodname>setResponseType()</methodname>
163 allow you to retrieve and modify the response type of the search between
164 <acronym>JSON</acronym> and Atom.