Programmer's Reference Guide

Zend_Service_ReCaptcha

Zend_Service_Simpy

Introduction

Zend_Service_Simpy is a lightweight wrapper for the free REST API available for the Simpy social bookmarking service.

In order to use Zend_Service_Simpy, you should already have a Simpy account. To get an account, visit the » Simpy web site. For more information on the Simpy REST API, refer to the » Simpy REST API documentation.

The Simpy REST API allows developers to interact with specific aspects of the service that the Simpy web site offers. The sections following will outline the use of Zend_Service_Simpy for each of these areas.

  • Links: Create, Retrieve, Update, Delete

  • Tags: Retrieve, Delete, Rename, Merge, Split

  • Notes: Create, Retrieve, Update, Delete

  • Watchlists: Get, Get All

Tags

When retrieved, tags are sorted in decreasing order (i.e. highest first) by the number of links that use the tag.

Example #3 Working With Tags

$simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');

/* Save a link with tags */
$simpy->saveLink(
    'Zend Framework' // Title
    'http://framework.zend.com', // URL
    Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC, // Access Type
    'zend, framework, php' // Tags
);

/* Get a list of all tags in use by links and notes */
$tagSet = $simpy->getTags();

/* Display each tag with the number of links using it */
foreach ($tagSet as $tag) {
    echo $tag->getTag();
    echo ' - ';
    echo $tag->getCount();
    echo '<br />';
}

/* Remove the 'zend' tag from all links using it */
$simpy->removeTag('zend');

/* Rename the 'framework' tag to 'frameworks' */
$simpy->renameTag('framework', 'frameworks');

/* Split the 'frameworks' tag into 'framework' and
'development', which will remove the 'frameworks' tag for
all links that use it and add the tags 'framework' and
'development' to all of those links */
$simpy->splitTag('frameworks', 'framework', 'development');

/* Merge the 'framework' and 'development' tags back into
'frameworks', basically doing the opposite of splitting them */
$simpy->mergeTags('framework', 'development', 'frameworks');

            

Notes

Notes can be saved, retrieved, and deleted. They are uniquely identified by a numeric ID value.

Example #4 Working With Notes

$simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');

/* Save a note */
$simpy->saveNote(
    'Test Note', // Title
    'test,note', // Tags
    'This is a test note.' // Description
);

/* Overwrite an existing note */
$simpy->saveNote(
    'Updated Test Note', // Title
    'test,note,updated', // Tags
    'This is an updated test note.', // Description
    $note->getId() // Unique identifier
);

/* Search for the 10 most recently added notes */
$noteSet = $simpy->getNotes(null, 10);

/* Display the notes */
foreach ($noteSet as $note) {
    echo '<p>';
    echo $note->getTitle();
    echo '<br />';
    echo $note->getDescription();
    echo '<br >';
    echo $note->getTags();
    echo '</p>';
}

/* Search for all notes with 'PHP' in the title */
$noteSet = $simpy->getNotes('title:PHP');

/* Search for all notes with 'PHP' in the title and
without 'framework' in the description */
$noteSet = $simpy->getNotes('+title:PHP -description:framework');

/* Delete a note */
$simpy->deleteNote($note->getId());

            

Watchlists

Watchlists cannot be created or removed using the API, only retrieved. Thus, you must set up a watchlist via the Simpy web site prior to attempting to access it using the API.

Example #5 Retrieving Watchlists

$simpy = new Zend_Service_Simpy('yourusername', 'yourpassword');

/* Get a list of all watchlists */
$watchlistSet = $simpy->getWatchlists();

/* Display data for each watchlist */
foreach ($watchlistSet as $watchlist) {
    echo $watchlist->getId();
    echo '<br />';
    echo $watchlist->getName();
    echo '<br />';
    echo $watchlist->getDescription();
    echo '<br />';
    echo $watchlist->getAddDate();
    echo '<br />';
    echo $watchlist->getNewLinks();
    echo '<br />';

    foreach ($watchlist->getUsers() as $user) {
        echo $user;
        echo '<br />';
    }

    foreach ($watchlist->getFilters() as $filter) {
        echo $filter->getName();
        echo '<br />';
        echo $filter->getQuery();
        echo '<br />';
    }
}

/* Get an individual watchlist by its identifier */
$watchlist = $simpy->getWatchlist($watchlist->getId());
$watchlist = $simpy->getWatchlist(1);

            

Zend_Service_ReCaptcha
blog comments powered by Disqus

Select a Version

Languages Available

Components

Search the Manual