View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Service_Simpy
{zone-data}

{zone-data:proposer-list}
[tobias382@gmail.com|mailto:tobias382@gmail.com]
{zone-data}

{zone-data:revision}
Jun 23, 2006
{zone-data}

{zone-data:overview}
Zend_Service_Simpy is a lightweight wrapper for the free REST API available for the Simpy social bookmarking service.
{zone-data}

{zone-data:references}
* [Simpy Services: REST API|http://www.simpy.com/simpy/service/api/rest/]
* [About Simpy|http://www.simpy.com/about]
{zone-data}

{zone-data:requirements}
* Accepts a username and password and handles user authentication via HTTP
* Implements all available API calls with consistent naming conventions.
* Returns server responses as lightweight data objects.
{zone-data}

{zone-data:dependencies}
* Zend_Http_Client
* Zend_Service_Exception
* Zend_Service_Rest
{zone-data}

{zone-data:operation}
Performs the requested API call and return the server response in the form of a data object.
{zone-data}

{zone-data:class-list}
* Zend_Service_Simpy
* Zend_Service_Simpy_Tag
* Zend_Service_Simpy_TagSet
* Zend_Service_Simpy_Link
* Zend_Service_Simpy_LinkSet
* Zend_Service_Simpy_Watchlist
* Zend_Service_Simpy_WatchlistSet
* Zend_Service_Simpy_Note
* Zend_Service_Simpy_NoteSet
{zone-data}

{zone-data:use-cases}
{code}
$simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');

$tagSet = $simpy->getTags(10);

foreach ($tagSet as $tag) {
echo $tag->tag . ' = ' . $tag->count . "\n";
}
{code}
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Service_Simpy
{
protected $_baseUri = '/simpy/api/rest/';

/**
* Public access type for links
*
* @var int
*/
const ACCESSTYPE_PUBLIC = 1;

/**
* Private access type for links
*
* @var int
*/
const ACCESSTYPE_PRIVATE = 0;

/**
* Zend_Service_Rest Object
*
* @var Zend_Service_Rest
*/
protected $_rest;

/**
* Constructs a new Simpy (free) REST API Client
*
* @param string $username Username for the Simpy user account
* @param string $password Password for the Simpy user account
* @return Zend_Service_Simpy
*/
public function __construct($username, $password);

/**
* Sends a request to the REST API service and does initial processing
* on the response.
*
* @param string $op Name of the operation for the request
* @param string|array $query Query data for the request
* @return DOMDocument Parsed XML response
*/
protected function _makeRequest($op, $query);

/**
* Returns a list of all tags and their counts, ordered by count in
* decreasing order
*
* @param int $limit Limits the number of tags returned (optional)
* @see http://www.simpy.com/simpy/service/api/rest/GetTags.jsp
* @throws Zend_Service_Exception
* @return Zend_Service_Simpy_TagSet
*/
public function getTags($limit = null);

/**
* Removes a tag.
*
* @param string $tag Tag to be removed
* @see http://www.simpy.com/simpy/service/api/rest/RemoveTag.jsp
* @return void
*/
public function removeTag($tag);

/**
* Renames a tag.
*
* @param string $fromTag Tag to be renamed
* @param string $toTag New tag name
* @see http://www.simpy.com/simpy/service/api/rest/RenameTag.jsp
* @return void
*/
public function renameTag($fromTag, $toTag);

/**
* Merges two tags into a new tag.
*
* @param string $fromTag1 First tag to merge.
* @param string $fromTag2 Second tag to merge.
* @param string $toTag Tag to merge the two tags into.
* @see http://www.simpy.com/simpy/service/api/rest/MergeTags.jsp
* @return void
*/
public function mergeTags($fromTag1, $fromTag2, $toTag);

/**
* Splits a single tag into two separate tags.
*
* @param string $tag Tag to split
* @param string $toTag1 First tag to split into
* @param string $toTag2 Second tag to split into
* @see http://www.simpy.com/simpy/service/api/rest/SplitTag.jsp
* @return void
*/
public function splitTag($tag, $toTag1, $toTag2);

/**
* Returns either most recent links, links added on or between given
* dates, links matching a given query, or links with a given tag.
*
* @param string $q Query string formatted using Simpy search syntax
* and search fields (optional)
* @param string $limit Limits the number of links returned (optional)
* @param string $date Limits the links returned to links added on the
* given date (optional)
* @param string $afterDate Limits the links returned to links added
* after (and excluding) the given date
* (optional)
* @param string $beforeDate Limits the links returned to links added
* before (and excluding) the given date
* (optional)
* @see http://www.simpy.com/simpy/service/api/rest/GetLinks.jsp
* @see http://www.simpy.com/simpy/FAQ.do#searchSyntax
* @see http://www.simpy.com/simpy/FAQ.do#searchFieldsLinks
* @return Zend_Service_Simpy_LinkSet
*/
public function getLinks($q = null, $limit = null, $date = null,
$afterDate = null, $beforeDate = null);

/**
* Saves a given link.
*
* @param string $title Title of the page to save
* @param string $href URL of the page to save
* @param int $accessType ACCESSTYPE_PUBLIC or ACCESSTYPE_PRIVATE
* @param string $tags Comma-separated list of tags (optional)
* @param string $urlNickname Alternative custom title (optional)
* @param string $note Free text note (optional)
* @link Zend_Service_Simpy::ACCESSTYPE_PUBLIC
* @link Zend_Service_Simpy::ACCESSTYPE_PRIVATE
* @see http://www.simpy.com/simpy/service/api/rest/SaveLink.
* @return void
*/
public function saveLink($title, $href, $accessType, $tags = null,
$urlNickname = null, $note = null);

/**
* Deletes a given link.
*
* @param string $href URL of the bookmark to delete
* @see http://www.simpy.com/simpy/service/api/rest/DeleteLink.jsp
* @return void
*/
public function deleteLink($href);

/**
* Return a list of watchlists and their meta-data, including the number
* of new links added to each watchlist since last login.
*
* @see http://www.simpy.com/simpy/service/api/rest/GetWatchlists.jsp
* @return Zend_Service_Simpy_WatchlistSet
*/
public function getWatchlists();

/**
* Returns the meta-data for a given watchlist.
*
* @param int $watchlistId ID of the watchlist to retrieve
* @see http://www.simpy.com/simpy/service/api/rest/GetWatchlist.jsp
* @return Zend_Service_Simpy_Watchlist
*/
public function getWatchlist($watchlistId);

/**
* Returns all notes in reverse chronological order by add date or by
* rank.
*
* @param string $q Query string formatted using Simpy search syntax
* and search fields (optional)
* @param int $limit Limits the number notes returned (optional)
* @see http://www.simpy.com/simpy/service/api/rest/GetNotes.jsp
* @see http://www.simpy.com/simpy/FAQ.do#searchSyntax
* @see http://www.simpy.com/simpy/FAQ.do#searchFieldsLinks
* @return Zend_Service_Simpy_NoteSet
*/
public function getNotes($q = null, $limit = null);

/**
* Saves a new note.
*
* @param string $title Title of the note
* @param string $tags Comma-separated list of tags (optional)
* @param string $description Free-text note (optional)
* @see http://www.simpy.com/simpy/service/api/rest/SaveNote.jsp
* @return void
*/
public function saveNote($title, $tags = null, $description = null);
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>