getPost() public method

public getPost ( $postID )
Esempio 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;
 }
Esempio n. 2
0
/**
 * @return String
 * @param String $username
 * @param String $password
 * @param String $host
 * @param String $path
 * @param String $type
 * @desc Connects, downloads the entry specified in the session, and returns it (title and content)
*/
function mt_open($username, $password, $host, $path, $type)
{
    if ($type == 'livejournal') {
        $mt = new bloggerclient($username, $password, $host, $path);
    } else {
        $mt = new mtclient($username, $password, $host, $path);
    }
    // Get the post id from the plugin identifier
    $at = strpos($_SESSION['plugin_identifier'], '@');
    $entry_id = urldecode(substr($_SESSION['plugin_identifier'], 1, $at - 1));
    $feed_id = urldecode(substr($_SESSION['plugin_identifier'], $at + 1, -1));
    $post = $mt->getPost($entry_id);
    $title = $post['title'];
    if ($title == '') {
        preg_match('/^<title>(.*)<\\/title>/sUi', $post['content'], $title);
        $post = trim($title[1]) . "\n" . trim(preg_replace('/^<title>(.*)<\\/title>/sUi', '', $post['content']));
    } else {
        $post = trim($title) . "\n" . trim($post['description']);
    }
    // Return the post, re-configured to suit webpad's display method
    return $post;
}