Zend_Service_Simpy.xml 10 KB

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