2
0

Zend_Service_Simpy.xml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.service.simpy">
  4. <title>Zend_Service_Simpy</title>
  5. <sect2 id="zend.service.simpy.introduction">
  6. <title>Introduction</title>
  7. <para>
  8. <classname>Zend_Service_Simpy</classname> is a lightweight wrapper for the free REST API available
  9. for the Simpy social bookmarking service.
  10. </para>
  11. <para>
  12. In order to use <classname>Zend_Service_Simpy</classname>, you should already have a Simpy account.
  13. To get an account, visit the <ulink url="http://simpy.com">Simpy web site</ulink>. For more
  14. information on the Simpy REST API, refer to the
  15. <ulink url="http://www.simpy.com/doc/api/rest">Simpy REST API documentation</ulink>.
  16. </para>
  17. <para>
  18. The Simpy REST API allows developers to interact with specific aspects of the service that
  19. the Simpy web site offers. The sections following will outline the use of
  20. <classname>Zend_Service_Simpy</classname> for each of these areas.
  21. <itemizedlist>
  22. <listitem>
  23. <para>
  24. Links: Create, Retrieve, Update, Delete
  25. </para>
  26. </listitem>
  27. <listitem>
  28. <para>
  29. Tags: Retrieve, Delete, Rename, Merge, Split
  30. </para>
  31. </listitem>
  32. <listitem>
  33. <para>
  34. Notes: Create, Retrieve, Update, Delete
  35. </para>
  36. </listitem>
  37. <listitem>
  38. <para>
  39. Watchlists: Get, Get All
  40. </para>
  41. </listitem>
  42. </itemizedlist>
  43. </para>
  44. </sect2>
  45. <sect2 id="zend.service.simpy.links">
  46. <title>Links</title>
  47. <para>
  48. When querying links, results are returned in descending order by date added. Links can be
  49. searched by title, nickname, tags, note, or even the content of the web page associated
  50. with the link. Simpy offers searching by any or all of these fields with phrases, boolean
  51. operators, and wildcards. See the
  52. <ulink url="http://www.simpy.com/faq#searchSyntax">search syntax</ulink> and
  53. <ulink url="http://www.simpy.com/faq#searchFieldsLinks">search fields</ulink>
  54. sections of the Simpy FAQ for more information.
  55. </para>
  56. <example id="zend.service.simpy.links.querying">
  57. <title>Querying Links</title>
  58. <programlisting language="php"><![CDATA[
  59. $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
  60. /* Search for the 10 links added most recently */
  61. $linkQuery = new Zend_Service_Simpy_LinkQuery();
  62. $linkQuery->setLimit(10);
  63. /* Get and display the links */
  64. $linkSet = $simpy->getLinks($linkQuery);
  65. foreach ($linkSet as $link) {
  66. echo '<a href="';
  67. echo $link->getUrl();
  68. echo '">';
  69. echo $link->getTitle();
  70. echo '</a><br />';
  71. }
  72. /* Search for the 5 links added most recently with 'PHP' in
  73. the title */
  74. $linkQuery->setQueryString('title:PHP');
  75. $linkQuery->setLimit(5);
  76. /* Search for all links with 'French' in the title and
  77. 'language' in the tags */
  78. $linkQuery->setQueryString('+title:French +tags:language');
  79. /* Search for all links with 'French' in the title and without
  80. 'travel' in the tags */
  81. $linkQuery->setQueryString('+title:French -tags:travel');
  82. /* Search for all links added on 12/9/06 */
  83. $linkQuery->setDate('2006-12-09');
  84. /* Search for all links added after 12/9/06 (excluding that
  85. date) */
  86. $linkQuery->setAfterDate('2006-12-09');
  87. /* Search for all links added before 12/9/06 (excluding that
  88. date) */
  89. $linkQuery->setBeforeDate('2006-12-09');
  90. /* Search for all links added between 12/1/06 and 12/9/06
  91. (excluding those two dates) */
  92. $linkQuery->setBeforeDate('2006-12-01');
  93. $linkQuery->setAfterDate('2006-12-09');
  94. ]]></programlisting>
  95. </example>
  96. <para>
  97. Links are represented uniquely by their URLs. In other words, if an attempt is made to save
  98. a link that has the same URL as an existing link, data for the existing link will be
  99. overwritten with the data specified in the save attempt.
  100. </para>
  101. <example id="zend.service.simpy.links.modifying">
  102. <title>Modifying Links</title>
  103. <programlisting language="php"><![CDATA[
  104. $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
  105. /* Save a link */
  106. $simpy->saveLink(
  107. 'Zend Framework' // Title
  108. 'http://framework.zend.com', // URL
  109. Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC, // Access Type
  110. 'zend, framework, php' // Tags
  111. 'Zend Framework home page' // Alternative title
  112. 'This site rocks!' // Note
  113. );
  114. /* Overwrite the existing link with new data */
  115. $simpy->saveLink(
  116. 'Zend Framework'
  117. 'http://framework.zend.com',
  118. Zend_Service_Simpy_Link::ACCESSTYPE_PRIVATE, // Access Type has changed
  119. 'php, zend, framework' // Tags have changed order
  120. 'Zend Framework' // Alternative title has changed
  121. 'This site REALLY rocks!' // Note has changed
  122. );
  123. /* Delete the link */
  124. $simpy->deleteLink('http://framework.zend.com');
  125. /* A really easy way to do spring cleaning on your links ;) */
  126. $linkSet = $this->_simpy->getLinks();
  127. foreach ($linkSet as $link) {
  128. $this->_simpy->deleteLink($link->getUrl());
  129. }
  130. ]]></programlisting>
  131. </example>
  132. </sect2>
  133. <sect2 id="zend.service.simpy.tags">
  134. <title>Tags</title>
  135. <para>
  136. When retrieved, tags are sorted in decreasing order (i.e. highest
  137. first) by the number of links that use the tag.
  138. </para>
  139. <example id="zend.service.simpy.tags.working">
  140. <title>Working With Tags</title>
  141. <programlisting language="php"><![CDATA[
  142. $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
  143. /* Save a link with tags */
  144. $simpy->saveLink(
  145. 'Zend Framework' // Title
  146. 'http://framework.zend.com', // URL
  147. Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC, // Access Type
  148. 'zend, framework, php' // Tags
  149. );
  150. /* Get a list of all tags in use by links and notes */
  151. $tagSet = $simpy->getTags();
  152. /* Display each tag with the number of links using it */
  153. foreach ($tagSet as $tag) {
  154. echo $tag->getTag();
  155. echo ' - ';
  156. echo $tag->getCount();
  157. echo '<br />';
  158. }
  159. /* Remove the 'zend' tag from all links using it */
  160. $simpy->removeTag('zend');
  161. /* Rename the 'framework' tag to 'frameworks' */
  162. $simpy->renameTag('framework', 'frameworks');
  163. /* Split the 'frameworks' tag into 'framework' and
  164. 'development', which will remove the 'frameworks' tag for
  165. all links that use it and add the tags 'framework' and
  166. 'development' to all of those links */
  167. $simpy->splitTag('frameworks', 'framework', 'development');
  168. /* Merge the 'framework' and 'development' tags back into
  169. 'frameworks', basically doing the opposite of splitting them */
  170. $simpy->mergeTags('framework', 'development', 'frameworks');
  171. ]]></programlisting>
  172. </example>
  173. </sect2>
  174. <sect2 id="zend.service.simpy.notes">
  175. <title>Notes</title>
  176. <para>
  177. Notes can be saved, retrieved, and deleted. They are uniquely
  178. identified by a numeric ID value.
  179. </para>
  180. <example id="zend.service.simpy.notes.working">
  181. <title>Working With Notes</title>
  182. <programlisting language="php"><![CDATA[
  183. $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
  184. /* Save a note */
  185. $simpy->saveNote(
  186. 'Test Note', // Title
  187. 'test,note', // Tags
  188. 'This is a test note.' // Description
  189. );
  190. /* Overwrite an existing note */
  191. $simpy->saveNote(
  192. 'Updated Test Note', // Title
  193. 'test,note,updated', // Tags
  194. 'This is an updated test note.', // Description
  195. $note->getId() // Unique identifier
  196. );
  197. /* Search for the 10 most recently added notes */
  198. $noteSet = $simpy->getNotes(null, 10);
  199. /* Display the notes */
  200. foreach ($noteSet as $note) {
  201. echo '<p>';
  202. echo $note->getTitle();
  203. echo '<br />';
  204. echo $note->getDescription();
  205. echo '<br >';
  206. echo $note->getTags();
  207. echo '</p>';
  208. }
  209. /* Search for all notes with 'PHP' in the title */
  210. $noteSet = $simpy->getNotes('title:PHP');
  211. /* Search for all notes with 'PHP' in the title and
  212. without 'framework' in the description */
  213. $noteSet = $simpy->getNotes('+title:PHP -description:framework');
  214. /* Delete a note */
  215. $simpy->deleteNote($note->getId());
  216. ]]></programlisting>
  217. </example>
  218. </sect2>
  219. <sect2 id="zend.service.simpy.watchlists">
  220. <title>Watchlists</title>
  221. <para>
  222. Watchlists cannot be created or removed using the API, only
  223. retrieved. Thus, you must set up a watchlist via the Simpy web
  224. site prior to attempting to access it using the API.
  225. </para>
  226. <example id="zend.service.simpy.watchlists.retrieving">
  227. <title>Retrieving Watchlists</title>
  228. <programlisting language="php"><![CDATA[
  229. $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
  230. /* Get a list of all watchlists */
  231. $watchlistSet = $simpy->getWatchlists();
  232. /* Display data for each watchlist */
  233. foreach ($watchlistSet as $watchlist) {
  234. echo $watchlist->getId();
  235. echo '<br />';
  236. echo $watchlist->getName();
  237. echo '<br />';
  238. echo $watchlist->getDescription();
  239. echo '<br />';
  240. echo $watchlist->getAddDate();
  241. echo '<br />';
  242. echo $watchlist->getNewLinks();
  243. echo '<br />';
  244. foreach ($watchlist->getUsers() as $user) {
  245. echo $user;
  246. echo '<br />';
  247. }
  248. foreach ($watchlist->getFilters() as $filter) {
  249. echo $filter->getName();
  250. echo '<br />';
  251. echo $filter->getQuery();
  252. echo '<br />';
  253. }
  254. }
  255. /* Get an individual watchlist by its identifier */
  256. $watchlist = $simpy->getWatchlist($watchlist->getId());
  257. $watchlist = $simpy->getWatchlist(1);
  258. ]]></programlisting>
  259. </example>
  260. </sect2>
  261. </sect1>
  262. <!--
  263. vim:se ts=4 sw=4 et:
  264. -->