1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.service.simpy">
4 <title>Zend_Service_Simpy</title>
6 <sect2 id="zend.service.simpy.introduction">
7 <title>Introduction</title>
10 <classname>Zend_Service_Simpy</classname> is a lightweight wrapper for the free REST
11 <acronym>API</acronym> available for the Simpy social bookmarking service.
15 In order to use <classname>Zend_Service_Simpy</classname>, you should already have a
16 Simpy account. To get an account, visit the <ulink
17 url="http://simpy.com">Simpy web site</ulink>. For more information on the Simpy
18 REST <acronym>API</acronym>, refer to the <ulink
19 url="http://www.simpy.com/doc/api/rest">Simpy REST <acronym>API</acronym>
20 documentation</ulink>.
24 The Simpy REST <acronym>API</acronym> allows developers to interact with specific
25 aspects of the service that the Simpy web site offers. The sections following will
26 outline the use of <classname>Zend_Service_Simpy</classname> for each of these areas.
31 Links: Create, Retrieve, Update, Delete
37 Tags: Retrieve, Delete, Rename, Merge, Split
43 Notes: Create, Retrieve, Update, Delete
49 Watchlists: Get, Get All
56 <sect2 id="zend.service.simpy.links">
60 When querying links, results are returned in descending order by date added. Links can
61 be searched by title, nickname, tags, note, or even the content of the web page
62 associated with the link. Simpy offers searching by any or all of these fields with
63 phrases, boolean operators, and wildcards. See the
64 <ulink url="http://www.simpy.com/faq#searchSyntax">search syntax</ulink> and
65 <ulink url="http://www.simpy.com/faq#searchFieldsLinks">search fields</ulink>
66 sections of the Simpy FAQ for more information.
69 <example id="zend.service.simpy.links.querying">
70 <title>Querying Links</title>
72 <programlisting language="php"><![CDATA[
73 $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
75 /* Search for the 10 links added most recently */
76 $linkQuery = new Zend_Service_Simpy_LinkQuery();
77 $linkQuery->setLimit(10);
79 /* Get and display the links */
80 $linkSet = $simpy->getLinks($linkQuery);
81 foreach ($linkSet as $link) {
85 echo $link->getTitle();
89 /* Search for the 5 links added most recently with 'PHP' in
91 $linkQuery->setQueryString('title:PHP');
92 $linkQuery->setLimit(5);
94 /* Search for all links with 'French' in the title and
95 'language' in the tags */
96 $linkQuery->setQueryString('+title:French +tags:language');
98 /* Search for all links with 'French' in the title and without
99 'travel' in the tags */
100 $linkQuery->setQueryString('+title:French -tags:travel');
102 /* Search for all links added on 12/9/06 */
103 $linkQuery->setDate('2006-12-09');
105 /* Search for all links added after 12/9/06 (excluding that
107 $linkQuery->setAfterDate('2006-12-09');
109 /* Search for all links added before 12/9/06 (excluding that
111 $linkQuery->setBeforeDate('2006-12-09');
113 /* Search for all links added between 12/1/06 and 12/9/06
114 (excluding those two dates) */
115 $linkQuery->setBeforeDate('2006-12-01');
116 $linkQuery->setAfterDate('2006-12-09');
121 Links are represented uniquely by their <acronym>URL</acronym>s. In other words, if an
122 attempt is made to save a link that has the same <acronym>URL</acronym> as an existing
123 link, data for the existing link will be overwritten with the data specified in the save
127 <example id="zend.service.simpy.links.modifying">
128 <title>Modifying Links</title>
130 <programlisting language="php"><![CDATA[
131 $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
135 'Zend Framework' // Title
136 'http://framework.zend.com', // URL
137 Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC, // Access Type
138 'zend, framework, php' // Tags
139 'Zend Framework home page' // Alternative title
140 'This site rocks!' // Note
143 /* Overwrite the existing link with new data */
146 'http://framework.zend.com',
147 Zend_Service_Simpy_Link::ACCESSTYPE_PRIVATE, // Access Type has changed
148 'php, zend, framework' // Tags have changed order
149 'Zend Framework' // Alternative title has changed
150 'This site REALLY rocks!' // Note has changed
153 /* Delete the link */
154 $simpy->deleteLink('http://framework.zend.com');
156 /* A really easy way to do spring cleaning on your links ;) */
157 $linkSet = $this->_simpy->getLinks();
158 foreach ($linkSet as $link) {
159 $this->_simpy->deleteLink($link->getUrl());
165 <sect2 id="zend.service.simpy.tags">
169 When retrieved, tags are sorted in decreasing order (i.e. highest
170 first) by the number of links that use the tag.
173 <example id="zend.service.simpy.tags.working">
174 <title>Working With Tags</title>
176 <programlisting language="php"><![CDATA[
177 $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
179 /* Save a link with tags */
181 'Zend Framework' // Title
182 'http://framework.zend.com', // URL
183 Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC, // Access Type
184 'zend, framework, php' // Tags
187 /* Get a list of all tags in use by links and notes */
188 $tagSet = $simpy->getTags();
190 /* Display each tag with the number of links using it */
191 foreach ($tagSet as $tag) {
194 echo $tag->getCount();
198 /* Remove the 'zend' tag from all links using it */
199 $simpy->removeTag('zend');
201 /* Rename the 'framework' tag to 'frameworks' */
202 $simpy->renameTag('framework', 'frameworks');
204 /* Split the 'frameworks' tag into 'framework' and
205 'development', which will remove the 'frameworks' tag for
206 all links that use it and add the tags 'framework' and
207 'development' to all of those links */
208 $simpy->splitTag('frameworks', 'framework', 'development');
210 /* Merge the 'framework' and 'development' tags back into
211 'frameworks', basically doing the opposite of splitting them */
212 $simpy->mergeTags('framework', 'development', 'frameworks');
217 <sect2 id="zend.service.simpy.notes">
221 Notes can be saved, retrieved, and deleted. They are uniquely
222 identified by a numeric ID value.
225 <example id="zend.service.simpy.notes.working">
226 <title>Working With Notes</title>
228 <programlisting language="php"><![CDATA[
229 $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
233 'Test Note', // Title
235 'This is a test note.' // Description
238 /* Overwrite an existing note */
240 'Updated Test Note', // Title
241 'test,note,updated', // Tags
242 'This is an updated test note.', // Description
243 $note->getId() // Unique identifier
246 /* Search for the 10 most recently added notes */
247 $noteSet = $simpy->getNotes(null, 10);
249 /* Display the notes */
250 foreach ($noteSet as $note) {
252 echo $note->getTitle();
254 echo $note->getDescription();
256 echo $note->getTags();
260 /* Search for all notes with 'PHP' in the title */
261 $noteSet = $simpy->getNotes('title:PHP');
263 /* Search for all notes with 'PHP' in the title and
264 without 'framework' in the description */
265 $noteSet = $simpy->getNotes('+title:PHP -description:framework');
268 $simpy->deleteNote($note->getId());
273 <sect2 id="zend.service.simpy.watchlists">
274 <title>Watchlists</title>
277 Watchlists cannot be created or removed using the <acronym>API</acronym>, only
278 retrieved. Thus, you must set up a watchlist via the Simpy web
279 site prior to attempting to access it using the <acronym>API</acronym>.
282 <example id="zend.service.simpy.watchlists.retrieving">
283 <title>Retrieving Watchlists</title>
285 <programlisting language="php"><![CDATA[
286 $simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');
288 /* Get a list of all watchlists */
289 $watchlistSet = $simpy->getWatchlists();
291 /* Display data for each watchlist */
292 foreach ($watchlistSet as $watchlist) {
293 echo $watchlist->getId();
295 echo $watchlist->getName();
297 echo $watchlist->getDescription();
299 echo $watchlist->getAddDate();
301 echo $watchlist->getNewLinks();
304 foreach ($watchlist->getUsers() as $user) {
309 foreach ($watchlist->getFilters() as $filter) {
310 echo $filter->getName();
312 echo $filter->getQuery();
317 /* Get an individual watchlist by its identifier */
318 $watchlist = $simpy->getWatchlist($watchlist->getId());
319 $watchlist = $simpy->getWatchlist(1);