Zend_Service_Twitter.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- EN-Revision: 21829 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="zend.service.twitter" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <title>Zend_Service_Twitter</title>
  6. <sect2 id="zend.service.twitter.introduction">
  7. <title>Introduction</title>
  8. <para>
  9. <classname>Zend_Service_Twitter</classname> fournit un client pour
  10. <ulink url="http://apiwiki.twitter.com/Twitter-API-Documentation">l'<acronym>API</acronym>
  11. <acronym>REST</acronym> de Twitter</ulink>.
  12. <classname>Zend_Service_Twitter</classname> vous permet d'interroger les fils (timeline) publics.
  13. En fournissant un nom d'utilisateur et un mot de passe pour Twitter, il vous permettra également
  14. de récupérer et mettre à jour votre statut, de répondre à des amis, de leur envoyer des messages
  15. directs, de marquer des tweets comme favoris et beaucoup d'autres choses.
  16. </para>
  17. <para>
  18. <classname>Zend_Service_Twitter</classname> implémente un service <acronym>REST</acronym>,
  19. et toutes ses méthodes retournes une instance de <classname>Zend_Rest_Client_Result</classname>.
  20. </para>
  21. <para>
  22. <classname>Zend_Service_Twitter</classname> et subdivisé en sections, ainsi vous pouvez
  23. facilement identifier le type d'appel qui est demandé.
  24. </para>
  25. <itemizedlist>
  26. <listitem>
  27. <para>
  28. <code>account</code> s'assure que vos données de compte sont valides, vérifie
  29. votre taux limite pour l'<acronym>API</acronym> et termine la session courante
  30. pour l'utilisateur authentifié.
  31. </para>
  32. </listitem>
  33. <listitem>
  34. <para>
  35. <code>status</code> retourne les fils publics et ceux de
  36. l'utilisateur et montre, met à jour, détruit et retourne des réponses
  37. pour l'utilisateur authentifié.
  38. </para>
  39. </listitem>
  40. <listitem>
  41. <para>
  42. <code>user</code> récupère les amis et 'followers' de l'utilisateur
  43. authentifié et retourne de plus amples informations sur l'utilisateur
  44. passé en paramètre.
  45. </para>
  46. </listitem>
  47. <listitem>
  48. <para>
  49. <code>directMessage</code> récupère les messages directs reçus par l'utilisateur
  50. authentifié, supprime les messages directs et permet également d'envoyer des
  51. messages directs.
  52. </para>
  53. </listitem>
  54. <listitem>
  55. <para>
  56. <code>friendship</code> crée et supprime des amitiés pour l'utilisateur
  57. authentifié.
  58. </para>
  59. </listitem>
  60. <listitem>
  61. <para>
  62. <code>favorite</code> liste, crée et détruit des tweets favoris.
  63. </para>
  64. </listitem>
  65. <listitem>
  66. <para>
  67. <code>block</code> bloque et débloque des utilisateurs qui vous suivent.
  68. </para>
  69. </listitem>
  70. </itemizedlist>
  71. </sect2>
  72. <sect2 id="zend.service.twitter.authentication">
  73. <title>Authentification</title>
  74. <para>
  75. A l'exception de la récupération du fil public, <classname>Zend_Service_Twitter</classname>
  76. nécessite une authentification pour fonctionner.
  77. Twitter utilise l'<ulink url="http://en.wikipedia.org/wiki/Basic_authentication_scheme">Authentification HTTP basique</ulink>.
  78. Vous pouvez lui passer votre nom d'utilisateur ou votre email utilisé pour l'enregistrement de votre compte
  79. ainsi que votre mot de passe pour vous connecter à Twitter.
  80. </para>
  81. <example id="zend.service.twitter.authentication.example">
  82. <title>Créer la classe Twitter</title>
  83. <para>
  84. L'exemple de code suivant décrit comment créer le service Twitter, lui passer
  85. vos nom d'utilisateur et mot de passe et vérifier qu'ils sont corrects.
  86. </para>
  87. <programlisting language="php"><![CDATA[
  88. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  89. // vérifie vos données de connexion avec Twitter
  90. $response = $twitter->account->verifyCredentials();
  91. ]]></programlisting>
  92. <para>
  93. Vous pouvez également passer un tableau qui contient le nom d'utilisateur
  94. et le mot de passe en tant que premier argument
  95. </para>
  96. <programlisting language="php"><![CDATA[
  97. $userInfo = array('username' => 'foo', 'password' => 'bar');
  98. $twitter = new Zend_Service_Twitter($userInfo);
  99. // vérifie vos données de connexion avec Twitter
  100. $response = $twitter->account->verifyCredentials();
  101. ]]></programlisting>
  102. </example>
  103. </sect2>
  104. <sect2 id="zend.service.twitter.account">
  105. <title>Account Methods</title>
  106. <itemizedlist>
  107. <listitem>
  108. <para>
  109. <methodname>verifyCredentials()</methodname> tests if supplied user
  110. credentials are valid with minimal overhead.
  111. </para>
  112. <example id="zend.service.twitter.account.verifycredentails">
  113. <title>Verifying credentials</title>
  114. <programlisting language="php"><![CDATA[
  115. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  116. $response = $twitter->account->verifyCredentials();
  117. ]]></programlisting>
  118. </example>
  119. </listitem>
  120. <listitem>
  121. <para>
  122. <methodname>endSession()</methodname> signs users out of
  123. client-facing applications.
  124. </para>
  125. <example id="zend.service.twitter.account.endsession">
  126. <title>Sessions ending</title>
  127. <programlisting language="php"><![CDATA[
  128. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  129. $response = $twitter->account->endSession();
  130. ]]></programlisting>
  131. </example>
  132. </listitem>
  133. <listitem>
  134. <para>
  135. <methodname>rateLimitStatus()</methodname> returns the remaining number of
  136. <acronym>API</acronym> requests available to the authenticating user
  137. before the <acronym>API</acronym> limit is reached for the current hour.
  138. </para>
  139. <example id="zend.service.twitter.account.ratelimitstatus">
  140. <title>Rating limit status</title>
  141. <programlisting language="php"><![CDATA[
  142. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  143. $response = $twitter->account->rateLimitStatus();
  144. ]]></programlisting>
  145. </example>
  146. </listitem>
  147. </itemizedlist>
  148. </sect2>
  149. <sect2 id="zend.service.twitter.status">
  150. <title>Status Methods</title>
  151. <itemizedlist>
  152. <listitem>
  153. <para>
  154. <methodname>publicTimeline()</methodname> returns the 20 most recent statuses
  155. from non-protected users with a custom user icon. The public timeline is cached
  156. by Twitter for 60 seconds.
  157. </para>
  158. <example id="zend.service.twitter.status.publictimeline">
  159. <title>Retrieving public timeline</title>
  160. <programlisting language="php"><![CDATA[
  161. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  162. $response = $twitter->status->publicTimeline();
  163. ]]></programlisting>
  164. </example>
  165. </listitem>
  166. <listitem>
  167. <para>
  168. <methodname>friendsTimeline()</methodname> returns the 20 most recent statuses
  169. posted by the authenticating user and that user's friends.
  170. </para>
  171. <example id="zend.service.twitter.status.friendstimeline">
  172. <title>Retrieving friends timeline</title>
  173. <programlisting language="php"><![CDATA[
  174. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  175. $response = $twitter->status->friendsTimeline();
  176. ]]></programlisting>
  177. </example>
  178. <para>
  179. The <methodname>friendsTimeline()</methodname> method accepts an array of
  180. optional parameters to modify the query.
  181. </para>
  182. <itemizedlist>
  183. <listitem>
  184. <para>
  185. <code>since</code> narrows the returned results to just those statuses
  186. created after the specified date/time (up to 24 hours old).
  187. </para>
  188. </listitem>
  189. <listitem>
  190. <para>
  191. <code>page</code> specifies which page you want to return.
  192. </para>
  193. </listitem>
  194. </itemizedlist>
  195. </listitem>
  196. <listitem>
  197. <para>
  198. <methodname>userTimeline()</methodname> returns the 20 most recent statuses
  199. posted from the authenticating user.
  200. </para>
  201. <example id="zend.service.twitter.status.usertimeline">
  202. <title>Retrieving user timeline</title>
  203. <programlisting language="php"><![CDATA[
  204. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  205. $response = $twitter->status->userTimeline();
  206. ]]></programlisting>
  207. </example>
  208. <para>
  209. The <methodname>userTimeline()</methodname> method accepts an array of optional
  210. parameters to modify the query.
  211. </para>
  212. <itemizedlist>
  213. <listitem>
  214. <para>
  215. <code>id</code> specifies the ID or screen name of the user for whom to
  216. return the friends_timeline.
  217. </para>
  218. </listitem>
  219. <listitem>
  220. <para>
  221. <code>since</code> narrows the returned results to just those statuses
  222. created after the specified date/time (up to 24 hours old).
  223. </para>
  224. </listitem>
  225. <listitem>
  226. <para>
  227. <code>page</code> specifies which page you want to return.
  228. </para>
  229. </listitem>
  230. <listitem>
  231. <para>
  232. <code>count</code> specifies the number of statuses to retrieve.
  233. May not be greater than 200.
  234. </para>
  235. </listitem>
  236. </itemizedlist>
  237. </listitem>
  238. <listitem>
  239. <para>
  240. <methodname>show()</methodname> returns a single status, specified by the
  241. <code>id</code> parameter below. The status' author will be returned inline.
  242. </para>
  243. <example id="zend.service.twitter.status.show">
  244. <title>Showing user status</title>
  245. <programlisting language="php"><![CDATA[
  246. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  247. $response = $twitter->status->show(1234);
  248. ]]></programlisting>
  249. </example>
  250. </listitem>
  251. <listitem>
  252. <para>
  253. <methodname>update()</methodname> updates the authenticating user's status.
  254. This method requires that you pass in the status update that you want to post
  255. to Twitter.
  256. </para>
  257. <example id="zend.service.twitter.status.update">
  258. <title>Updating user status</title>
  259. <programlisting language="php"><![CDATA[
  260. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  261. $response = $twitter->status->update('My Great Tweet');
  262. ]]></programlisting>
  263. </example>
  264. <para>
  265. The <methodname>update()</methodname> method accepts a second additional
  266. parameter.
  267. </para>
  268. <itemizedlist>
  269. <listitem>
  270. <para>
  271. <code>in_reply_to_status_id</code> specifies the ID of an existing
  272. status that the status to be posted is in reply to.
  273. </para>
  274. </listitem>
  275. </itemizedlist>
  276. </listitem>
  277. <listitem>
  278. <para>
  279. <methodname>replies()</methodname> returns the 20 most recent @replies (status
  280. updates prefixed with @username) for the authenticating user.
  281. </para>
  282. <example id="zend.service.twitter.status.replies">
  283. <title>Showing user replies</title>
  284. <programlisting language="php"><![CDATA[
  285. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  286. $response = $twitter->status->replies();
  287. ]]></programlisting>
  288. </example>
  289. <para>
  290. The <methodname>replies()</methodname> method accepts an array of optional
  291. parameters to modify the query.
  292. </para>
  293. <itemizedlist>
  294. <listitem>
  295. <para>
  296. <code>since</code> narrows the returned results to just those statuses
  297. created after the specified date/time (up to 24 hours old).
  298. </para>
  299. </listitem>
  300. <listitem>
  301. <para>
  302. <code>page</code> specifies which page you want to return.
  303. </para>
  304. </listitem>
  305. <listitem>
  306. <para>
  307. <code>since_id</code> returns only statuses with an ID greater than
  308. (that is, more recent than) the specified ID.
  309. </para>
  310. </listitem>
  311. </itemizedlist>
  312. </listitem>
  313. <listitem>
  314. <para>
  315. <methodname>destroy()</methodname> destroys the status specified by the
  316. required <code>id</code> parameter.
  317. </para>
  318. <example id="zend.service.twitter.status.destroy">
  319. <title>Deleting user status</title>
  320. <programlisting language="php"><![CDATA[
  321. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  322. $response = $twitter->status->destroy(12345);
  323. ]]></programlisting>
  324. </example>
  325. </listitem>
  326. </itemizedlist>
  327. </sect2>
  328. <sect2 id="zend.service.twitter.user">
  329. <title>User Methods</title>
  330. <itemizedlist>
  331. <listitem>
  332. <para>
  333. <methodname>friends()</methodname>r eturns up to 100 of the authenticating
  334. user's friends who have most recently updated, each with current status inline.
  335. </para>
  336. <example id="zend.service.twitter.user.friends">
  337. <title>Retrieving user friends</title>
  338. <programlisting language="php"><![CDATA[
  339. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  340. $response = $twitter->user->friends();
  341. ]]></programlisting>
  342. </example>
  343. <para>
  344. The <methodname>friends()</methodname> method accepts an array of optional
  345. parameters to modify the query.
  346. </para>
  347. <itemizedlist>
  348. <listitem>
  349. <para>
  350. <code>id</code> specifies the ID or screen name of the user for whom to
  351. return a list of friends.
  352. </para>
  353. </listitem>
  354. <listitem>
  355. <para>
  356. <code>since</code> narrows the returned results to just those statuses
  357. created after the specified date/time (up to 24 hours old).
  358. </para>
  359. </listitem>
  360. <listitem>
  361. <para>
  362. <code>page</code> specifies which page you want to return.
  363. </para>
  364. </listitem>
  365. </itemizedlist>
  366. </listitem>
  367. <listitem>
  368. <para>
  369. <methodname>followers()</methodname> returns the authenticating user's
  370. followers, each with current status inline.
  371. </para>
  372. <example id="zend.service.twitter.user.followers">
  373. <title>Retrieving user followers</title>
  374. <programlisting language="php"><![CDATA[
  375. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  376. $response = $twitter->user->followers();
  377. ]]></programlisting>
  378. </example>
  379. <para>
  380. The <methodname>followers()</methodname> method accepts an array of optional
  381. parameters to modify the query.
  382. </para>
  383. <itemizedlist>
  384. <listitem>
  385. <para>
  386. <code>id</code> specifies the ID or screen name of the user for whom to
  387. return a list of followers.
  388. </para>
  389. </listitem>
  390. <listitem>
  391. <para>
  392. <code>page</code> specifies which page you want to return.
  393. </para>
  394. </listitem>
  395. </itemizedlist>
  396. </listitem>
  397. <listitem>
  398. <para>
  399. <methodname>show()</methodname> returns extended information of a given user,
  400. specified by ID or screen name as per the required <code>id</code>
  401. parameter below.
  402. </para>
  403. <example id="zend.service.twitter.user.show">
  404. <title>Showing user informations</title>
  405. <programlisting language="php"><![CDATA[
  406. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  407. $response = $twitter->user->show('myfriend');
  408. ]]></programlisting>
  409. </example>
  410. </listitem>
  411. </itemizedlist>
  412. </sect2>
  413. <sect2 id="zend.service.twitter.directmessage">
  414. <title>Direct Message Methods</title>
  415. <itemizedlist>
  416. <listitem>
  417. <para>
  418. <methodname>messages()</methodname> returns a list of the 20 most recent direct
  419. messages sent to the authenticating user.
  420. </para>
  421. <example id="zend.service.twitter.directmessage.messages">
  422. <title>Retrieving recent direct messages received</title>
  423. <programlisting language="php"><![CDATA[
  424. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  425. $response = $twitter->directMessage->messages();
  426. ]]></programlisting>
  427. </example>
  428. <para>
  429. The <methodname>message()</methodname> method accepts an array of optional
  430. parameters to modify the query.
  431. </para>
  432. <itemizedlist>
  433. <listitem>
  434. <para>
  435. <code>since_id</code> returns only direct messages with an ID greater
  436. than (that is, more recent than) the specified ID.
  437. </para>
  438. </listitem>
  439. <listitem>
  440. <para>
  441. <code>since</code> narrows the returned results to just those statuses
  442. created after the specified date/time (up to 24 hours old).
  443. </para>
  444. </listitem>
  445. <listitem>
  446. <para>
  447. <code>page</code> specifies which page you want to return.
  448. </para>
  449. </listitem>
  450. </itemizedlist>
  451. </listitem>
  452. <listitem>
  453. <para>
  454. <methodname>sent()</methodname> returns a list of the 20 most recent direct
  455. messages sent by the authenticating user.
  456. </para>
  457. <example id="zend.service.twitter.directmessage.sent">
  458. <title>Retrieving recent direct messages sent</title>
  459. <programlisting language="php"><![CDATA[
  460. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  461. $response = $twitter->directMessage->sent();
  462. ]]></programlisting>
  463. </example>
  464. <para>
  465. The <methodname>sent()</methodname> method accepts an array of optional
  466. parameters to modify the query.
  467. </para>
  468. <itemizedlist>
  469. <listitem>
  470. <para>
  471. <code>since_id</code> returns only direct messages with an ID greater
  472. than (that is, more recent than) the specified ID.
  473. </para>
  474. </listitem>
  475. <listitem>
  476. <para>
  477. <code>since</code> narrows the returned results to just those statuses
  478. created after the specified date/time (up to 24 hours old).
  479. </para>
  480. </listitem>
  481. <listitem>
  482. <para>
  483. <code>page</code> specifies which page you want to return.
  484. </para>
  485. </listitem>
  486. </itemizedlist>
  487. </listitem>
  488. <listitem>
  489. <para>
  490. <methodname>new()</methodname> sends a new direct message to the specified user
  491. from the authenticating user. Requires both the user and text parameters below.
  492. </para>
  493. <example id="zend.service.twitter.directmessage.new">
  494. <title>Sending direct message</title>
  495. <programlisting language="php"><![CDATA[
  496. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  497. $response = $twitter->directMessage->new('myfriend', 'mymessage');
  498. ]]></programlisting>
  499. </example>
  500. </listitem>
  501. <listitem>
  502. <para>
  503. <methodname>destroy()</methodname> destroys the direct message specified in the
  504. required <code>id</code> parameter. The authenticating user must be the
  505. recipient of the specified direct message.
  506. </para>
  507. <example id="zend.service.twitter.directmessage.destroy">
  508. <title>Deleting direct message</title>
  509. <programlisting language="php"><![CDATA[
  510. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  511. $response = $twitter->directMessage->destroy(123548);
  512. ]]></programlisting>
  513. </example>
  514. </listitem>
  515. </itemizedlist>
  516. </sect2>
  517. <sect2 id="zend.service.twitter.friendship">
  518. <title>Friendship Methods</title>
  519. <itemizedlist>
  520. <listitem>
  521. <para>
  522. <methodname>create()</methodname> befriends the user specified in the
  523. <code>id</code> parameter with the authenticating user.
  524. </para>
  525. <example id="zend.service.twitter.friendship.create">
  526. <title>Creating friend</title>
  527. <programlisting language="php"><![CDATA[
  528. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  529. $response = $twitter->friendship->create('mynewfriend');
  530. ]]></programlisting>
  531. </example>
  532. </listitem>
  533. <listitem>
  534. <para>
  535. <methodname>destroy()</methodname> discontinues friendship with the user
  536. specified in the <code>id</code> parameter and the authenticating user.
  537. </para>
  538. <example id="zend.service.twitter.friendship.destroy">
  539. <title>Deleting friend</title>
  540. <programlisting language="php"><![CDATA[
  541. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  542. $response = $twitter->friendship->destroy('myoldfriend');
  543. ]]></programlisting>
  544. </example>
  545. </listitem>
  546. <listitem>
  547. <para>
  548. <methodname>exists()</methodname> tests if a friendship exists between the
  549. user specified in the <code>id</code> parameter and the authenticating user.
  550. </para>
  551. <example id="zend.service.twitter.friendship.exists">
  552. <title>Checking friend existence</title>
  553. <programlisting language="php"><![CDATA[
  554. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  555. $response = $twitter->friendship->exists('myfriend');
  556. ]]></programlisting>
  557. </example>
  558. </listitem>
  559. </itemizedlist>
  560. </sect2>
  561. <sect2 id="zend.service.twitter.favorite">
  562. <title>Favorite Methods</title>
  563. <itemizedlist>
  564. <listitem>
  565. <para>
  566. <methodname>favorites()</methodname> returns the 20 most recent favorite
  567. statuses for the authenticating user or user specified by the
  568. <code>id</code> parameter.
  569. </para>
  570. <example id="zend.service.twitter.favorite.favorites">
  571. <title>Retrieving favorites</title>
  572. <programlisting language="php"><![CDATA[
  573. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  574. $response = $twitter->favorite->favorites();
  575. ]]></programlisting>
  576. </example>
  577. <para>
  578. The <methodname>favorites()</methodname> method accepts an array of optional
  579. parameters to modify the query.
  580. </para>
  581. <itemizedlist>
  582. <listitem>
  583. <para>
  584. <code>id</code> specifies the ID or screen name of the user for whom to
  585. request a list of favorite statuses.
  586. </para>
  587. </listitem>
  588. <listitem>
  589. <para>
  590. <code>page</code> specifies which page you want to return.
  591. </para>
  592. </listitem>
  593. </itemizedlist>
  594. </listitem>
  595. <listitem>
  596. <para>
  597. <methodname>create()</methodname> favorites the status specified in the
  598. <code>id</code> parameter as the authenticating user.
  599. </para>
  600. <example id="zend.service.twitter.favorite.create">
  601. <title>Creating favorites</title>
  602. <programlisting language="php"><![CDATA[
  603. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  604. $response = $twitter->favorite->create(12351);
  605. ]]></programlisting>
  606. </example>
  607. </listitem>
  608. <listitem>
  609. <para>
  610. <methodname>destroy()</methodname> un-favorites the status specified in the
  611. <code>id</code> parameter as the authenticating user.
  612. </para>
  613. <example id="zend.service.twitter.favorite.destroy">
  614. <title>Deleting favorites</title>
  615. <programlisting language="php"><![CDATA[
  616. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  617. $response = $twitter->favorite->destroy(12351);
  618. ]]></programlisting>
  619. </example>
  620. </listitem>
  621. </itemizedlist>
  622. </sect2>
  623. <sect2 id="zend.service.twitter.block">
  624. <title>Block Methods</title>
  625. <itemizedlist>
  626. <listitem>
  627. <para>
  628. <methodname>exists()</methodname> checks if the authenticating user is blocking
  629. a target user and can optionally return the blocked user's object if a
  630. block does exists.
  631. </para>
  632. <example id="zend.service.twitter.block.exists">
  633. <title>Checking if block exists</title>
  634. <programlisting language="php"><![CDATA[
  635. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  636. // returns true or false
  637. $response = $twitter->block->exists('blockeduser');
  638. // returns the blocked user's info if the user is blocked
  639. $response2 = $twitter->block->exists('blockeduser', true);
  640. ]]></programlisting>
  641. </example>
  642. <para>
  643. The <methodname>favorites()</methodname> method accepts a second
  644. optional parameter.
  645. </para>
  646. <itemizedlist>
  647. <listitem>
  648. <para>
  649. <code>returnResult</code> specifies whether or not return the user
  650. object instead of just <constant>TRUE</constant> or
  651. <constant>FALSE</constant>.
  652. </para>
  653. </listitem>
  654. </itemizedlist>
  655. </listitem>
  656. <listitem>
  657. <para>
  658. <methodname>create()</methodname> blocks the user specified in the
  659. <code>id</code> parameter as the authenticating user and destroys a friendship
  660. to the blocked user if one exists. Returns the blocked user in the requested
  661. format when successful.
  662. </para>
  663. <example id="zend.service.twitter.block.create">
  664. <title>Blocking a user</title>
  665. <programlisting language="php"><![CDATA[
  666. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  667. $response = $twitter->block->create('usertoblock);
  668. ]]></programlisting>
  669. </example>
  670. </listitem>
  671. <listitem>
  672. <para>
  673. <methodname>destroy()</methodname> un-blocks the user specified in the
  674. <code>id</code> parameter for the authenticating user. Returns the un-blocked
  675. user in the requested format when successful.
  676. </para>
  677. <example id="zend.service.twitter.block.destroy">
  678. <title>Removing a block</title>
  679. <programlisting language="php"><![CDATA[
  680. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  681. $response = $twitter->block->destroy('blockeduser');
  682. ]]></programlisting>
  683. </example>
  684. </listitem>
  685. <listitem>
  686. <para>
  687. <methodname>blocking()</methodname> returns an array of user objects that the
  688. authenticating user is blocking.
  689. </para>
  690. <example id="zend.service.twitter.block.blocking">
  691. <title>Who are you blocking</title>
  692. <programlisting language="php"><![CDATA[
  693. $twitter = new Zend_Service_Twitter('myusername', 'mysecretpassword');
  694. // return the full user list from the first page
  695. $response = $twitter->block->blocking();
  696. // return an array of numeric user IDs from the second page
  697. $response2 = $twitter->block->blocking(2, true);
  698. ]]></programlisting>
  699. </example>
  700. <para>
  701. The <methodname>favorites()</methodname> method accepts two optional parameters.
  702. </para>
  703. <itemizedlist>
  704. <listitem>
  705. <para>
  706. <code>page</code> specifies which page ou want to return. A single page
  707. contains 20 IDs.
  708. </para>
  709. </listitem>
  710. <listitem>
  711. <para>
  712. <code>returnUserIds</code> specifies whether to return an array of
  713. numeric user IDs the authenticating user is blocking instead of an
  714. array of user objects.
  715. </para>
  716. </listitem>
  717. </itemizedlist>
  718. </listitem>
  719. </itemizedlist>
  720. </sect2>
  721. <xi:include href="Zend_Service_Twitter_Search.xml">
  722. <xi:fallback>
  723. <xi:include href="../../en/module_specs/Zend_Service_Twitter_Search.xml" />
  724. </xi:fallback>
  725. </xi:include>
  726. </sect1>
  727. <!--
  728. vim:se ts=4 sw=4 et:
  729. -->