Instances of this class are returned by the getPosts(),
getAllPosts(), getRecentPosts(), and
getUserPosts() methods of
Zend_Service_Delicious.
For easier data access this class implements the Countable,
Iterator, and ArrayAccess interfaces.
Example 769. Accessing post lists
<?php
$delicious = new Zend_Service_Delicious('username', 'password');
$posts = $delicious->getAllPosts();
// count posts
echo count($posts);
// iterate over posts
foreach ($posts as $post) {
echo "--\n";
echo "Title: {$post->getTitle()}\n";
echo "Url: {$post->getUrl()}\n";
}
// get post using array access
echo $posts[0]->getTitle();
Note
The ArrayAccess::offsetSet() and
ArrayAccess::offsetUnset() methods throw exceptions in this
implementation. Thus, code like unset($posts[0]); and
$posts[0] = 'A'; will throw exceptions because these properties are
read-only.
Post list objects have two built-in filtering capabilities. Post lists may be filtered by tags and by URL.
Example 770. Filtering a Post List with Specific Tags
Posts may be filtered by specific tags using withTags(). As
a convenience, withTag() is also provided for when only a
single tag needs to be specified.
<?php
$delicious = new Zend_Service_Delicious('username', 'password');
$posts = $delicious->getAllPosts();
// Print posts having "php" and "zend" tags
foreach ($posts->withTags(array('php', 'zend')) as $post) {
echo "Title: {$post->getTitle()}\n";
echo "Url: {$post->getUrl()}\n";
}
Example 771. Filtering a Post List by URL
Posts may be filtered by URL matching a specified regular
expression using the withUrl() method:
<?php
$delicious = new Zend_Service_Delicious('username', 'password');
$posts = $delicious->getAllPosts();
// Print posts having "help" in the URL
foreach ($posts->withUrl('/help/') as $post) {
echo "Title: {$post->getTitle()}\n";
echo "Url: {$post->getUrl()}\n";
}




