Zend_Service_Twitter.xml 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.service.twitter" xmlns:xi="http://www.w3.org/2001/XInclude">
  4. <title>Zend_Service_Twitter</title>
  5. <sect2 id="zend.service.twitter.introduction">
  6. <title>Introduction</title>
  7. <para>
  8. <classname>Zend_Service_Twitter</classname> provides a client for the
  9. <ulink url="https://dev.twitter.com/docs/api/1.1">Twitter <acronym>API</acronym></ulink>.
  10. <classname>Zend_Service_Twitter</classname> allows you to query the public timeline. If
  11. you provide a username and OAuth details for Twitter, it will allow you to get and update
  12. your status, reply to friends, direct message friends, mark tweets as favorite, and
  13. much more.
  14. </para>
  15. <para>
  16. <classname>Zend_Service_Twitter</classname> wraps all web service
  17. operations, including OAuth, and all methods return an instance of
  18. <classname>Zend_Service_Twitter_Response</classname>.
  19. </para>
  20. <para>
  21. <classname>Zend_Service_Twitter</classname> is broken up into subsections so you can
  22. easily identify which type of call is being requested.
  23. </para>
  24. <itemizedlist>
  25. <listitem>
  26. <para>
  27. <code>account</code> allows you to check that your account credentials are
  28. valid.
  29. </para>
  30. </listitem>
  31. <listitem>
  32. <para>
  33. <code>application</code> allows you to check your <acronym>API</acronym> rate
  34. limit.
  35. </para>
  36. </listitem>
  37. <listitem>
  38. <para>
  39. <code>blocks</code> blocks and unblocks users from following you.
  40. </para>
  41. </listitem>
  42. <listitem>
  43. <para>
  44. <code>directMessages</code> retrieves the authenticated user's received direct
  45. messages, deletes direct messages, and sends new direct messages.
  46. </para>
  47. </listitem>
  48. <listitem>
  49. <para>
  50. <code>favorites</code> lists, creates, and removes favorite tweets.
  51. </para>
  52. </listitem>
  53. <listitem>
  54. <para>
  55. <code>friendships</code> creates and removes friendships for the
  56. authenticated user.
  57. </para>
  58. </listitem>
  59. <listitem>
  60. <para>
  61. <code>search</code> allows you to search statuses for specific criteria.
  62. </para>
  63. </listitem>
  64. <listitem>
  65. <para>
  66. <code>statuses</code> retrieves the public and user timelines and
  67. shows, updates, destroys, and retrieves replies for the authenticated user.
  68. </para>
  69. </listitem>
  70. <listitem>
  71. <para>
  72. <code>users</code> retrieves friends and followers for the authenticated user
  73. and returns extended information about a passed user.
  74. </para>
  75. </listitem>
  76. </itemizedlist>
  77. </sect2>
  78. <sect2 id="zend.service.twitter.authentication">
  79. <title>Authentication</title>
  80. <para>
  81. With the exception of fetching the public timeline,
  82. <classname>Zend_Service_Twitter</classname> requires authentication as a valid
  83. user. This is achieved using the OAuth authentication protocol. OAuth is
  84. the only supported authentication mode for Twitter as of August 2010. The OAuth
  85. implementation used by <classname>Zend_Service_Twitter</classname> is
  86. <classname>Zend_Oauth</classname>.
  87. </para>
  88. <example id="zend.service.twitter.authentication.example">
  89. <title>Creating the Twitter Class</title>
  90. <para>
  91. <classname>Zend_Service_Twitter</classname> must authorize itself, on behalf of a user, before use with the
  92. Twitter API (except for public timeline). This must be accomplished using OAuth since
  93. Twitter has disabled it's basic HTTP authentication as of August 2010.
  94. </para>
  95. <para>
  96. There are two options to establishing authorization. The first is to implement the
  97. workflow of <classname>Zend_Oauth</classname> via <classname>Zend_Service_Twitter</classname>
  98. which proxies to an internal <classname>Zend_Oauth_Consumer</classname> object. Please refer to
  99. the <classname>Zend_Oauth</classname> documentation for a full example of this
  100. workflow - you can call all documented <classname>Zend_Oauth_Consumer</classname> methods
  101. on <classname>Zend_Service_Twitter</classname> including constructor options. You may also
  102. use <classname>Zend_Oauth</classname> directly and only pass the resulting access
  103. token into <classname>Zend_Service_Twitter</classname>. This is the normal workflow
  104. once you have established a reusable access token for a particular Twitter user. The resulting OAuth
  105. access token should be stored to a database for future use (otherwise you will need to
  106. authorize for every new instance of <classname>Zend_Service_Twitter</classname>). Bear in mind
  107. that authorization via OAuth results in your user being redirected to Twitter to give their
  108. consent to the requested authorization (this is not repeated for stored access tokens). This will
  109. require additional work (i.e. redirecting users and hosting a callback URL) over the previous
  110. HTTP authentication mechanism where a user just
  111. needed to allow applications to store their username and password.
  112. </para>
  113. <para>The following example demonstrates setting up <classname>Zend_Service_Twitter</classname>
  114. which is given an already established OAuth access token. Please refer to the <classname>Zend_Oauth</classname>
  115. documentation to understand the workflow involved. The access token is a serializable object, so you may
  116. store the serialized object to a database, and unserialize it at retrieval time before passing the objects
  117. into <classname>Zend_Service_Twitter</classname>. The <classname>Zend_Oauth</classname> documentation
  118. demonstrates the workflow and objects involved.</para>
  119. <programlisting language="php"><![CDATA[
  120. /**
  121. * We assume $serializedToken is the serialized token retrieved from a database
  122. * or even $_SESSION (if following the simple Zend_Oauth documented example)
  123. */
  124. $token = unserialize($serializedToken);
  125. $twitter = new Zend_Service_Twitter(array(
  126. 'accessToken' => $token
  127. 'oauth_options' => array(
  128. 'username' => 'johndoe',
  129. ),
  130. ));
  131. // verify user's credentials with Twitter
  132. $response = $twitter->account->verifyCredentials();
  133. ]]></programlisting>
  134. </example>
  135. <note>
  136. <para>
  137. In order to authenticate with Twitter, ALL applications MUST be registered with
  138. Twitter in order to receive a Consumer Key and Consumer Secret to be used when
  139. authenticating with OAuth. This can not be reused across multiple applications -
  140. you must register each new application separately. Twitter access tokens have
  141. no expiry date, so storing them to a database is advised (they can, of course,
  142. be refreshed simply be repeating the OAuth authorization process). This can only
  143. be done while interacting with the user associated with that access token.
  144. </para>
  145. <para>
  146. The previous pre-OAuth version of <classname>Zend_Service_Twitter</classname>
  147. allowed passing in a username as the first parameter rather than within an array.
  148. This is no longer supported.
  149. </para>
  150. </note>
  151. <para>
  152. If you have registered an application with Twitter, you can also use the access token
  153. and access token secret they provide you in order to setup the OAuth consumer. This can
  154. be done as follows:
  155. </para>
  156. <programlisting language="php"><![CDATA[
  157. $twitter = new Zend_Service_Twitter(array(
  158. 'access_token' => array( // or use "accessToken" as the key; both work
  159. 'token' => 'your-access-token',
  160. 'secret' => 'your-access-token-secret',
  161. ),
  162. 'oauth_options' => array( // or use "oauthOptions" as the key; both work
  163. 'consumerKey' => 'your-consumer-key',
  164. 'consumerSecret' => 'your-consumer-secret',
  165. ),
  166. ));
  167. ]]></programlisting>
  168. <para>
  169. If desired, you can also specify a specific HTTP client instance to use, or provide
  170. configuration for the HTTP client. To provide the HTTP client, use the
  171. <varname>http_client</varname> or <varname>httpClient</varname> key, and provide an
  172. instance. To provide HTTP client configuration for setting up an instance, use the key
  173. <varname>http_client_options</varname> or <varname>httpClientOptions</varname>. As a
  174. full example:
  175. </para>
  176. <programlisting language="php"><![CDATA[
  177. $twitter = new Zend_Service_Twitter(array(
  178. 'access_token' => array( // or use "accessToken" as the key; both work
  179. 'token' => 'your-access-token',
  180. 'secret' => 'your-access-token-secret',
  181. ),
  182. 'oauth_options' => array( // or use "oauthOptions" as the key; both work
  183. 'consumerKey' => 'your-consumer-key',
  184. 'consumerSecret' => 'your-consumer-secret',
  185. ),
  186. 'http_client_options' => array(
  187. 'adapter' => 'Zend_Http_Client_Adapter_Curl',
  188. ),
  189. ));
  190. ]]></programlisting>
  191. </sect2>
  192. <sect2 id="zend.service.twitter.account">
  193. <title>Account Methods</title>
  194. <itemizedlist>
  195. <listitem>
  196. <para>
  197. <methodname>verifyCredentials()</methodname> tests if supplied user
  198. credentials are valid with minimal overhead.
  199. </para>
  200. <example id="zend.service.twitter.account.verifycredentails">
  201. <title>Verifying credentials</title>
  202. <programlisting language="php"><![CDATA[
  203. $twitter = new Zend_Service_Twitter($options);
  204. $response = $twitter->account->verifyCredentials();
  205. ]]></programlisting>
  206. </example>
  207. </listitem>
  208. </itemizedlist>
  209. </sect2>
  210. <sect2 id="zend.service.twitter.application">
  211. <title>Application Methods</title>
  212. <itemizedlist>
  213. <listitem>
  214. <para>
  215. <methodname>rateLimitStatus()</methodname> returns the remaining number of
  216. <acronym>API</acronym> requests available to the authenticating user
  217. before the <acronym>API</acronym> limit is reached for the current hour.
  218. </para>
  219. <example id="zend.service.twitter.application.ratelimitstatus">
  220. <title>Rating limit status</title>
  221. <programlisting language="php"><![CDATA[
  222. $twitter = new Zend_Service_Twitter($options);
  223. $response = $twitter->application->rateLimitStatus();
  224. $userTimelineLimit = $response->resources->statuses->{'/statuses/user_timeline'}->remaining;
  225. ]]></programlisting>
  226. </example>
  227. </listitem>
  228. </itemizedlist>
  229. </sect2>
  230. <sect2 id="zend.service.twitter.blocks">
  231. <title>Block Methods</title>
  232. <itemizedlist>
  233. <listitem>
  234. <para>
  235. <methodname>create()</methodname> blocks the user specified in the
  236. <code>id</code> parameter as the authenticating user and destroys a friendship
  237. to the blocked user if one exists. Returns the blocked user when successful.
  238. </para>
  239. <example id="zend.service.twitter.blocks.create">
  240. <title>Blocking a user</title>
  241. <programlisting language="php"><![CDATA[
  242. $twitter = new Zend_Service_Twitter($options);
  243. $response = $twitter->blocks->create('usertoblock');
  244. ]]></programlisting>
  245. </example>
  246. </listitem>
  247. <listitem>
  248. <para>
  249. <methodname>destroy()</methodname> un-blocks the user specified in the
  250. <code>id</code> parameter for the authenticating user. Returns the un-blocked
  251. user in the requested format when successful.
  252. </para>
  253. <example id="zend.service.twitter.blocks.destroy">
  254. <title>Removing a block</title>
  255. <programlisting language="php"><![CDATA[
  256. $twitter = new Zend_Service_Twitter($options);
  257. $response = $twitter->blocks->destroy('blockeduser');
  258. ]]></programlisting>
  259. </example>
  260. </listitem>
  261. <listitem>
  262. <para>
  263. <methodname>ids()</methodname> returns an array of user identifiers that the
  264. authenticating user is blocking.
  265. </para>
  266. <example id="zend.service.twitter.blocks.ids">
  267. <title>Who are you blocking (identifiers only)</title>
  268. <programlisting language="php"><![CDATA[
  269. $twitter = new Zend_Service_Twitter($options);
  270. $response = $twitter->blocks->ids();
  271. ]]></programlisting>
  272. </example>
  273. </listitem>
  274. <listitem>
  275. <para>
  276. <methodname>list()</methodname> returns an array of user objects that the
  277. authenticating user is blocking.
  278. </para>
  279. <example id="zend.service.twitter.blocks.list">
  280. <title>Who are you blocking</title>
  281. <programlisting language="php"><![CDATA[
  282. $twitter = new Zend_Service_Twitter($options);
  283. $response = $twitter->blocks->list();
  284. ]]></programlisting>
  285. </example>
  286. </listitem>
  287. </itemizedlist>
  288. </sect2>
  289. <sect2 id="zend.service.twitter.directmessages">
  290. <title>Direct Message Methods</title>
  291. <itemizedlist>
  292. <listitem>
  293. <para>
  294. <methodname>messages()</methodname> returns a list of the 20 most recent direct
  295. messages sent to the authenticating user.
  296. </para>
  297. <example id="zend.service.twitter.directmessages.messages">
  298. <title>Retrieving recent direct messages received</title>
  299. <programlisting language="php"><![CDATA[
  300. $twitter = new Zend_Service_Twitter($options);
  301. $response = $twitter->directMessages->messages();
  302. ]]></programlisting>
  303. </example>
  304. <para>
  305. The <methodname>messages()</methodname> method accepts an array of optional
  306. parameters to modify the query.
  307. </para>
  308. <itemizedlist>
  309. <listitem>
  310. <para>
  311. <code>since_id</code> narrows the returned results to just those
  312. statuses after the specified identifier (up to 24 hours old).
  313. </para>
  314. </listitem>
  315. <listitem>
  316. <para>
  317. <code>max_id</code> narrows the returned results to just those
  318. statuses earlier than the specified identifier.
  319. </para>
  320. </listitem>
  321. <listitem>
  322. <para>
  323. <code>count</code> specifies the number of statuses to return, up to 200.
  324. </para>
  325. </listitem>
  326. <listitem>
  327. <para>
  328. <code>skip_status</code>, when set to boolean true, "t", or 1 will skip
  329. including a user's most recent status in the results.
  330. </para>
  331. </listitem>
  332. <listitem>
  333. <para>
  334. <code>include_entities</code> controls whether or not entities, which
  335. includes URLs, mentioned users, and hashtags, will be returned.
  336. </para>
  337. </listitem>
  338. </itemizedlist>
  339. </listitem>
  340. <listitem>
  341. <para>
  342. <methodname>sent()</methodname> returns a list of the 20 most recent direct
  343. messages sent by the authenticating user.
  344. </para>
  345. <example id="zend.service.twitter.directmessages.sent">
  346. <title>Retrieving recent direct messages sent</title>
  347. <programlisting language="php"><![CDATA[
  348. $twitter = new Zend_Service_Twitter($options);
  349. $response = $twitter->directMessages->sent();
  350. ]]></programlisting>
  351. </example>
  352. <para>
  353. The <methodname>sent()</methodname> method accepts an array of optional
  354. parameters to modify the query.
  355. </para>
  356. <itemizedlist>
  357. <listitem>
  358. <para>
  359. <code>count</code> specifies the number of statuses to return, up to 20.
  360. </para>
  361. </listitem>
  362. <listitem>
  363. <para>
  364. <code>page</code> specifies the page of results to return, based on the
  365. <code>count</code> provided.
  366. </para>
  367. </listitem>
  368. <listitem>
  369. <para>
  370. <code>since_id</code> narrows the returned results to just those
  371. statuses after the specified identifier (up to 24 hours old).
  372. </para>
  373. </listitem>
  374. <listitem>
  375. <para>
  376. <code>max_id</code> narrows the returned results to just those
  377. statuses earlier than the specified identifier.
  378. </para>
  379. </listitem>
  380. <listitem>
  381. <para>
  382. <code>include_entities</code> controls whether or not entities, which
  383. includes URLs, mentioned users, and hashtags, will be returned.
  384. </para>
  385. </listitem>
  386. </itemizedlist>
  387. </listitem>
  388. <listitem>
  389. <para>
  390. <methodname>new()</methodname> sends a new direct message to the specified user
  391. from the authenticating user. Requires both the user and text parameters below.
  392. </para>
  393. <example id="zend.service.twitter.directmessages.new">
  394. <title>Sending a direct message</title>
  395. <programlisting language="php"><![CDATA[
  396. $twitter = new Zend_Service_Twitter($options);
  397. $response = $twitter->directMessages->new('myfriend', 'mymessage');
  398. ]]></programlisting>
  399. </example>
  400. </listitem>
  401. <listitem>
  402. <para>
  403. <methodname>destroy()</methodname> destroys the direct message specified in the
  404. required <code>id</code> parameter. The authenticating user must be the
  405. recipient of the specified direct message.
  406. </para>
  407. <example id="zend.service.twitter.directmessages.destroy">
  408. <title>Deleting a direct message</title>
  409. <programlisting language="php"><![CDATA[
  410. $twitter = new Zend_Service_Twitter($options);
  411. $response = $twitter->directMessages->destroy(123548);
  412. ]]></programlisting>
  413. </example>
  414. </listitem>
  415. </itemizedlist>
  416. </sect2>
  417. <sect2 id="zend.service.twitter.favorites">
  418. <title>Favorites Methods</title>
  419. <itemizedlist>
  420. <listitem>
  421. <para>
  422. <methodname>list()</methodname> returns the 20 most recent favorite
  423. statuses for the authenticating user or user specified by the
  424. <code>user_id</code> or <code>screen_name</code> parameter.
  425. </para>
  426. <example id="zend.service.twitter.favorites.list">
  427. <title>Retrieving favorites</title>
  428. <programlisting language="php"><![CDATA[
  429. $twitter = new Zend_Service_Twitter($options);
  430. $response = $twitter->favorites->list();
  431. ]]></programlisting>
  432. </example>
  433. <para>
  434. The <methodname>list()</methodname> method accepts an array of optional
  435. parameters to modify the query.
  436. </para>
  437. <itemizedlist>
  438. <listitem>
  439. <para>
  440. <code>user_id</code> specifies the ID of the user for whom to return the
  441. timeline.
  442. </para>
  443. </listitem>
  444. <listitem>
  445. <para>
  446. <code>screen_name</code> specifies the screen name of the user for
  447. whom to return the timeline.
  448. </para>
  449. </listitem>
  450. <listitem>
  451. <para>
  452. <code>since_id</code> narrows the returned results to just those
  453. statuses after the specified identifier (up to 24 hours old).
  454. </para>
  455. </listitem>
  456. <listitem>
  457. <para>
  458. <code>max_id</code> narrows the returned results to just those
  459. statuses earlier than the specified identifier.
  460. </para>
  461. </listitem>
  462. <listitem>
  463. <para>
  464. <code>count</code> specifies the number of statuses to return, up to 200.
  465. </para>
  466. </listitem>
  467. <listitem>
  468. <para>
  469. <code>include_entities</code> controls whether or not entities, which
  470. includes URLs, mentioned users, and hashtags, will be returned.
  471. </para>
  472. </listitem>
  473. </itemizedlist>
  474. </listitem>
  475. <listitem>
  476. <para>
  477. <methodname>create()</methodname> favorites the status specified in the
  478. <code>id</code> parameter as the authenticating user.
  479. </para>
  480. <example id="zend.service.twitter.favorites.create">
  481. <title>Creating a favorite</title>
  482. <programlisting language="php"><![CDATA[
  483. $twitter = new Zend_Service_Twitter($options);
  484. $response = $twitter->favorites->create(12351);
  485. ]]></programlisting>
  486. </example>
  487. </listitem>
  488. <listitem>
  489. <para>
  490. <methodname>destroy()</methodname> un-favorites the status specified in the
  491. <code>id</code> parameter as the authenticating user.
  492. </para>
  493. <example id="zend.service.twitter.favorites.destroy">
  494. <title>Deleting favorites</title>
  495. <programlisting language="php"><![CDATA[
  496. $twitter = new Zend_Service_Twitter($options);
  497. $response = $twitter->favorites->destroy(12351);
  498. ]]></programlisting>
  499. </example>
  500. </listitem>
  501. </itemizedlist>
  502. </sect2>
  503. <sect2 id="zend.service.twitter.friendships">
  504. <title>Friendship Methods</title>
  505. <itemizedlist>
  506. <listitem>
  507. <para>
  508. <methodname>create()</methodname> befriends the user specified in the
  509. <code>id</code> parameter with the authenticating user.
  510. </para>
  511. <example id="zend.service.twitter.friendships.create">
  512. <title>Creating a friend</title>
  513. <programlisting language="php"><![CDATA[
  514. $twitter = new Zend_Service_Twitter($options);
  515. $response = $twitter->friendships->create('mynewfriend');
  516. ]]></programlisting>
  517. </example>
  518. </listitem>
  519. <listitem>
  520. <para>
  521. <methodname>destroy()</methodname> discontinues friendship with the user
  522. specified in the <code>id</code> parameter and the authenticating user.
  523. </para>
  524. <example id="zend.service.twitter.friendships.destroy">
  525. <title>Deleting a friend</title>
  526. <programlisting language="php"><![CDATA[
  527. $twitter = new Zend_Service_Twitter($options);
  528. $response = $twitter->friendships->destroy('myoldfriend');
  529. ]]></programlisting>
  530. </example>
  531. </listitem>
  532. </itemizedlist>
  533. </sect2>
  534. <sect2 id="zend.service.twitter.search">
  535. <title>Search Methods</title>
  536. <itemizedlist>
  537. <listitem>
  538. <para>
  539. <methodname>tweets()</methodname> returns a list of tweets matching the criteria
  540. specified in <varname>$query</varname>. By default, 15 will be returned, but
  541. this value may be changed using the <varname>count</varname> option.
  542. </para>
  543. <example id="zend.service.twitter.search.tweets">
  544. <title>Searching for tweets</title>
  545. <programlisting language="php"><![CDATA[
  546. $twitter = new Zend_Service_Twitter($options);
  547. $response = $twitter->search->tweets('#zendframework');
  548. ]]></programlisting>
  549. </example>
  550. <para>
  551. The <methodname>tweets()</methodname> method accepts an optional second
  552. argument, an array of optional parameters to modify the query.
  553. </para>
  554. <itemizedlist>
  555. <listitem>
  556. <para>
  557. <code>since_id</code> narrows the returned results to just those
  558. statuses after the specified identifier (up to 24 hours old).
  559. </para>
  560. </listitem>
  561. <listitem>
  562. <para>
  563. <code>max_id</code> narrows the returned results to just those
  564. statuses earlier than the specified identifier.
  565. </para>
  566. </listitem>
  567. <listitem>
  568. <para>
  569. <code>count</code> specifies the number of statuses to return, up to 200.
  570. </para>
  571. </listitem>
  572. <listitem>
  573. <para>
  574. <code>include_entities</code> controls whether or not entities, which
  575. includes URLs, mentioned users, and hashtags, will be returned.
  576. </para>
  577. </listitem>
  578. <listitem>
  579. <para>
  580. <code>lang</code> indicates which two-letter language code to restrict
  581. results to.
  582. </para>
  583. </listitem>
  584. <listitem>
  585. <para>
  586. <code>locale</code> indicates which two-letter language code is being
  587. used in the query.
  588. </para>
  589. </listitem>
  590. <listitem>
  591. <para>
  592. <code>geocode</code> can be used to indicate the geographical radius in
  593. which tweets should originate; the string should be in the form
  594. "latitude,longitude,radius", with "radius" being a unit followed by one
  595. of "mi" or "km".
  596. </para>
  597. </listitem>
  598. <listitem>
  599. <para>
  600. <code>result_type</code> indicates what type of results to retrieve, and
  601. should be one of "mixed," "recent," or "popular."
  602. </para>
  603. </listitem>
  604. <listitem>
  605. <para>
  606. <code>until</code> can be used to specify a the latest date for which to
  607. return tweets.
  608. </para>
  609. </listitem>
  610. </itemizedlist>
  611. </listitem>
  612. </itemizedlist>
  613. </sect2>
  614. <sect2 id="zend.service.twitter.statuses">
  615. <title>Status Methods</title>
  616. <itemizedlist>
  617. <listitem>
  618. <para>
  619. <methodname>sample()</methodname> returns the 20 most recent statuses
  620. from non-protected users with a custom user icon. The public timeline is cached
  621. by Twitter for 60 seconds.
  622. </para>
  623. <example id="zend.service.twitter.statuses.sample">
  624. <title>Retrieving public timeline</title>
  625. <programlisting language="php"><![CDATA[
  626. $twitter = new Zend_Service_Twitter($options);
  627. $response = $twitter->statuses->sample();
  628. ]]></programlisting>
  629. </example>
  630. </listitem>
  631. <listitem>
  632. <para>
  633. <methodname>homeTimeline()</methodname> returns the 20 most recent statuses
  634. posted by the authenticating user and that user's friends.
  635. </para>
  636. <example id="zend.service.twitter.statuses.hometimeline">
  637. <title>Retrieving the home timeline</title>
  638. <programlisting language="php"><![CDATA[
  639. $twitter = new Zend_Service_Twitter($options);
  640. ));
  641. $response = $twitter->statuses->homeTimeline();
  642. ]]></programlisting>
  643. </example>
  644. <para>
  645. The <methodname>homeTimeline()</methodname> method accepts an array of
  646. optional parameters to modify the query.
  647. </para>
  648. <itemizedlist>
  649. <listitem>
  650. <para>
  651. <code>since_id</code> narrows the returned results to just those
  652. statuses after the specified identifier (up to 24 hours old).
  653. </para>
  654. </listitem>
  655. <listitem>
  656. <para>
  657. <code>max_id</code> narrows the returned results to just those
  658. statuses earlier than the specified identifier.
  659. </para>
  660. </listitem>
  661. <listitem>
  662. <para>
  663. <code>count</code> specifies the number of statuses to return, up to 200.
  664. </para>
  665. </listitem>
  666. <listitem>
  667. <para>
  668. <code>trim_user</code>, when set to boolean true, "t", or 1, will list
  669. the author identifier only in embedded user objects in the statuses
  670. returned.
  671. </para>
  672. </listitem>
  673. <listitem>
  674. <para>
  675. <code>contributor_details</code>, when set to boolean true, will return
  676. the screen name of any contributors to a status (instead of only the
  677. contributor identifier).
  678. </para>
  679. </listitem>
  680. <listitem>
  681. <para>
  682. <code>include_entities</code> controls whether or not entities, which
  683. includes URLs, mentioned users, and hashtags, will be returned.
  684. </para>
  685. </listitem>
  686. <listitem>
  687. <para>
  688. <code>exclude_replies</code> controls whether or not status updates that
  689. are in reply to other statuses will be returned.
  690. </para>
  691. </listitem>
  692. </itemizedlist>
  693. </listitem>
  694. <listitem>
  695. <para>
  696. <methodname>userTimeline()</methodname> returns the 20 most recent statuses
  697. posted from the authenticating user.
  698. </para>
  699. <example id="zend.service.twitter.statuses.usertimeline">
  700. <title>Retrieving user timeline</title>
  701. <programlisting language="php"><![CDATA[
  702. $twitter = new Zend_Service_Twitter($options);
  703. $response = $twitter->statuses->userTimeline();
  704. ]]></programlisting>
  705. </example>
  706. <para>
  707. The <methodname>userTimeline()</methodname> method accepts an array of optional
  708. parameters to modify the query.
  709. </para>
  710. <itemizedlist>
  711. <listitem>
  712. <para>
  713. <code>user_id</code> specifies the ID of the user for whom to return the
  714. timeline.
  715. </para>
  716. </listitem>
  717. <listitem>
  718. <para>
  719. <code>screen_name</code> specifies the screen name of the user for
  720. whom to return the timeline.
  721. </para>
  722. </listitem>
  723. <listitem>
  724. <para>
  725. <code>since_id</code> narrows the returned results to just those
  726. statuses after the specified identifier (up to 24 hours old).
  727. </para>
  728. </listitem>
  729. <listitem>
  730. <para>
  731. <code>max_id</code> narrows the returned results to just those
  732. statuses earlier than the specified identifier.
  733. </para>
  734. </listitem>
  735. <listitem>
  736. <para>
  737. <code>count</code> specifies the number of statuses to return, up to 200.
  738. </para>
  739. </listitem>
  740. <listitem>
  741. <para>
  742. <code>trim_user</code>, when set to boolean true, "t", or 1, will list
  743. the author identifier only in embedded user objects in the statuses
  744. returned.
  745. </para>
  746. </listitem>
  747. <listitem>
  748. <para>
  749. <code>contributor_details</code>, when set to boolean true, will return
  750. the screen name of any contributors to a status (instead of only the
  751. contributor identifier).
  752. </para>
  753. </listitem>
  754. <listitem>
  755. <para>
  756. <code>include_rts</code> controls whether or not to include native
  757. retweets in the returned list.
  758. </para>
  759. </listitem>
  760. <listitem>
  761. <para>
  762. <code>exclude_replies</code> controls whether or not status updates that
  763. are in reply to other statuses will be returned.
  764. </para>
  765. </listitem>
  766. </itemizedlist>
  767. </listitem>
  768. <listitem>
  769. <para>
  770. <methodname>show()</methodname> returns a single status, specified by the
  771. <code>id</code> parameter below. The status' author will be returned inline.
  772. </para>
  773. <example id="zend.service.twitter.statuses.show">
  774. <title>Showing user status</title>
  775. <programlisting language="php"><![CDATA[
  776. $twitter = new Zend_Service_Twitter($options);
  777. $response = $twitter->statuses->show(1234);
  778. ]]></programlisting>
  779. </example>
  780. </listitem>
  781. <listitem>
  782. <para>
  783. <methodname>update()</methodname> updates the authenticating user's status.
  784. This method requires that you pass in the status update that you want to post
  785. to Twitter.
  786. </para>
  787. <example id="zend.service.twitter.statuses.update">
  788. <title>Updating user status</title>
  789. <programlisting language="php"><![CDATA[
  790. $twitter = new Zend_Service_Twitter($options);
  791. $response = $twitter->statuses->update('My Great Tweet');
  792. ]]></programlisting>
  793. </example>
  794. <para>
  795. The <methodname>update()</methodname> method accepts a second additional
  796. parameter.
  797. </para>
  798. <itemizedlist>
  799. <listitem>
  800. <para>
  801. <code>inReplyToStatusId</code> specifies the ID of an existing
  802. status that the status to be posted is in reply to.
  803. </para>
  804. </listitem>
  805. </itemizedlist>
  806. </listitem>
  807. <listitem>
  808. <para>
  809. <methodname>mentionsTimeline()</methodname> returns the 20 most recent @replies
  810. (status updates prefixed with @username) for the authenticating user.
  811. </para>
  812. <example id="zend.service.twitter.statuses.mentionstimeline">
  813. <title>Showing user replies</title>
  814. <programlisting language="php"><![CDATA[
  815. $twitter = new Zend_Service_Twitter($options);
  816. $response = $twitter->statuses->mentionsTimeline();
  817. ]]></programlisting>
  818. </example>
  819. <para>
  820. The <methodname>mentionsTimeline()</methodname> method accepts an array of
  821. optional parameters to modify the query.
  822. </para>
  823. <itemizedlist>
  824. <listitem>
  825. <para>
  826. <code>since_id</code> narrows the returned results to just those
  827. statuses after the specified identifier (up to 24 hours old).
  828. </para>
  829. </listitem>
  830. <listitem>
  831. <para>
  832. <code>max_id</code> narrows the returned results to just those
  833. statuses earlier than the specified identifier.
  834. </para>
  835. </listitem>
  836. <listitem>
  837. <para>
  838. <code>count</code> specifies the number of statuses to return, up to 200.
  839. </para>
  840. </listitem>
  841. <listitem>
  842. <para>
  843. <code>trim_user</code>, when set to boolean true, "t", or 1, will list
  844. the author identifier only in embedded user objects in the statuses
  845. returned.
  846. </para>
  847. </listitem>
  848. <listitem>
  849. <para>
  850. <code>contributor_details</code>, when set to boolean true, will return
  851. the screen name of any contributors to a status (instead of only the
  852. contributor identifier).
  853. </para>
  854. </listitem>
  855. <listitem>
  856. <para>
  857. <code>include_entities</code> controls whether or not entities, which
  858. includes URLs, mentioned users, and hashtags, will be returned.
  859. </para>
  860. </listitem>
  861. </itemizedlist>
  862. </listitem>
  863. <listitem>
  864. <para>
  865. <methodname>destroy()</methodname> destroys the status specified by the
  866. required <code>id</code> parameter.
  867. </para>
  868. <example id="zend.service.twitter.statuses.destroy">
  869. <title>Deleting user status</title>
  870. <programlisting language="php"><![CDATA[
  871. $twitter = new Zend_Service_Twitter($options);
  872. $response = $twitter->statuses->destroy(12345);
  873. ]]></programlisting>
  874. </example>
  875. </listitem>
  876. </itemizedlist>
  877. </sect2>
  878. <sect2 id="zend.service.twitter.users">
  879. <title>User Methods</title>
  880. <itemizedlist>
  881. <listitem>
  882. <para>
  883. <methodname>show()</methodname> returns extended information of a given user,
  884. specified by ID or screen name as per the required <code>id</code>
  885. parameter below.
  886. </para>
  887. <example id="zend.service.twitter.users.show">
  888. <title>Showing user informations</title>
  889. <programlisting language="php"><![CDATA[
  890. $twitter = new Zend_Service_Twitter($options);
  891. $response = $twitter->users->show('myfriend');
  892. ]]></programlisting>
  893. </example>
  894. </listitem>
  895. <listitem>
  896. <para>
  897. <methodname>search()</methodname> will search for users matching the query
  898. provided.
  899. </para>
  900. <example id="zend.service.twitter.users.search">
  901. <title>Searching for users</title>
  902. <programlisting language="php"><![CDATA[
  903. $twitter = new Zend_Service_Twitter($options);
  904. $response = $twitter->users->search('Zend');
  905. ]]></programlisting>
  906. </example>
  907. <para>
  908. The <methodname>search()</methodname> method accepts an array of
  909. optional parameters to modify the query.
  910. </para>
  911. <itemizedlist>
  912. <listitem>
  913. <para>
  914. <code>count</code> specifies the number of statuses to return, up to 20.
  915. </para>
  916. </listitem>
  917. <listitem>
  918. <para>
  919. <code>page</code> specifies the page of results to return, based on the
  920. <code>count</code> provided.
  921. </para>
  922. </listitem>
  923. <listitem>
  924. <para>
  925. <code>include_entities</code> controls whether or not entities, which
  926. includes URLs, mentioned users, and hashtags, will be returned.
  927. </para>
  928. </listitem>
  929. </itemizedlist>
  930. </listitem>
  931. </itemizedlist>
  932. </sect2>
  933. </sect1>
  934. <!--
  935. vim:se ts=4 sw=4 et:
  936. -->