Zend_Service_Twitter.xml 33 KB

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