mtclient::getRecentPosts PHP Method

getRecentPosts() public method

public getRecentPosts ( $blogID, $numPosts )
    function getRecentPosts($blogID, $numPosts)
    {
        $XMLblogid = new xmlrpcval($blogID, "string");
        $XMLnumPosts = new xmlrpcval($numPosts, "int");
        $r = new xmlrpcmsg("metaWeblog.getRecentPosts", array($XMLblogid, $this->XMLusername, $this->XMLpassword, $XMLnumPosts));
        $r = $this->exec($r);
        return $r;
    }

Usage Example

Ejemplo n.º 1
0
 protected function getResource($ticket, $path)
 {
     if (false === ($session = $this->retrieveSessionData($ticket))) {
         throw new Exception('Could not load blogposts. Session error.');
     }
     $resource = array();
     $blog = new mtclient($session[0], $session[1], $session[2], $session[3]);
     if ('/' == $path) {
         $posts = $blog->getRecentPosts(1, 20);
         if (!is_array($posts)) {
             throw new Exception('Could not load blogposts from server.');
         }
         foreach ($posts as $post) {
             $basename = $post['title'] . '.html';
             $resources[] = array('basename' => $basename, 'is_collection' => false);
             $map['/' . $basename] = $post['postid'];
         }
         $session[5] = $map;
         $this->storeSessionData($ticket, $session);
     } else {
         $map = $session[5];
         if (isset($map[$path])) {
             $postid = $map[$path];
             $post = $blog->getPost($postid);
             if (!is_array($post)) {
                 throw new Exception("Could not load blogpost `{$postid}' from server.");
             }
             $resources = $post['description'];
         }
     }
     return $resources;
 }
All Usage Examples Of mtclient::getRecentPosts