Example #1
0
/**
 * wp.getPage
 *
 * @see http://codex.wordpress.org/XML-RPC_wp#wp.getPage
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 blogid (int): Unique identifier of the blog.
 *					1 page_id (int): Requested page ID.
 *					2 username (string): User login.
 *					3 password (string): Password for said username.
 */
function wp_getpage($m)
{
    logIO('wp_getpage start');
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 2, 3))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET BLOG:
    /**
     * @var Blog
     */
    if (!($Blog =& xmlrpcs_get_Blog($m, 0))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    $item_ID = $m->getParam(1);
    $item_ID = abs($item_ID->scalarval());
    $items = xmlrpc_get_items(array('item_ID' => $item_ID), $Blog);
    if (empty($items)) {
        return xmlrpcs_resperror(6, 'Requested post/Item (' . $item_ID . ') does not exist.');
    }
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($items[0], 'struct'));
}
Example #2
0
/**
 * metaWeblog.getRecentPosts
 *
 * @see http://xmlrpc.scripting.com/metaWeblogApi.html#metawebloggetrecentposts
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 blogid (string): Unique identifier of the blog the post will be added to.
 *						Currently ignored in b2evo, in favor of the category.
 *					1 username (string): Login for a Blogger user who has permission to edit the given
 *						post (either the user who originally created it or an admin of the blog).
 *					2 password (string): Password for said username.
 *					3 numposts (integer): number of posts to retrieve.
 */
function mw_getrecentposts($m)
{
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET BLOG:
    /**
     * @var Blog
     */
    if (!($Blog =& xmlrpcs_get_Blog($m, 0))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    $limit = $m->getParam(3);
    $limit = abs($limit->scalarval());
    $items = xmlrpc_get_items(array('limit' => $limit), $Blog);
    if (empty($items)) {
        return new xmlrpcresp(new xmlrpcval(array(), 'array'));
    }
    $data = array();
    foreach ($items as $item) {
        $data[] = new xmlrpcval($item, 'struct');
    }
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($data, 'array'));
}