/** * The getRecentPostTitles method is intended to retrieve the given number of * post titles from a blog. * The posts themselves can be retrieved with getPost() or getPosts(). * * @param int $number The number of posts to be retrieved. * * @return Array An array of int => strings representing the * post ids (key) and their title (value). */ public function getRecentPostTitles($number = 15) { if ($number > 50) { $number = 50; } $authdata = $this->getAuthData(); $value = new XML_RPC_Value(array('username' => $this->userdata['rpc_user'], 'auth_method' => new XML_RPC_Value('challenge', 'string'), 'auth_challenge' => new XML_RPC_Value($authdata['challenge'], 'string'), 'auth_response' => new XML_RPC_Value($authdata['response'], 'string'), 'selecttype' => new XML_RPC_Value('lastn', 'string'), 'howmany' => new XML_RPC_Value($number, 'int'), 'prefersubject' => new XML_RPC_Value(true, 'boolean'), 'truncate' => new XML_RPC_Value(50, 'string'), 'noprops' => new XML_RPC_Value(true, 'boolean')), 'struct'); $request = new XML_RPC_Message('LJ.XMLRPC.getevents', array($value)); $arData = Services_Blogging_XmlRpc::sendRequest($request, $this->rpc_client); $arTitles = array(); foreach ($arData['events'] as $event) { $arTitles[$event['itemid']] = $event['event']; } return $arTitles; }
/** * Returns an array of recent posts as Services_Blogging_Post objects * * @param int $number The number of posts to be retrieved. * Defaults to 15 * * @return Array An array of objects of the Services_Blogging_Post class that * correspond to the number of posts requested. */ public function getRecentPosts($number = 15) { $request = new XML_RPC_Message('metaWeblog.getRecentPosts', array($this->userdata['rpc_blogid'], $this->userdata['rpc_user'], $this->userdata['rpc_pass'], new XML_RPC_Value($number, 'int'))); $arData = Services_Blogging_XmlRpc::sendRequest($request, $this->rpc_client); $arPosts = array(); foreach ($arData as $data) { $post = $this->convertStructToPost($data); $arPosts[$post->id] = $post; } return $arPosts; }
/** * Implements the blogger.setTemplate() method. The BlogID of the blog for * which the template is to be set, the template type * (again: 'main' or 'archiveIndex') * and the actual template in the HTML format are passed as parameters. * * See the docblock for the getTemplate() to find out what a template is. * * @param string $tempType The type of the template being set. Either 'main' * or 'archiveIndex'. * @param string $template The actual template in the HTML format. * * @return boolean Whether or not the template was set. */ public function setTemplate($tempType, $template) { if ($tempType != 'main' && $tempType != 'archiveIndex') { throw new Services_Blogging_Driver_Exception('Unknown template "' . $tempType . '"', self::ERROR_UNKNOWN_TEMPLATE); } $request = new XML_RPC_Message('blogger.setTemplate', array($this->userdata['rpc_key'], $this->userdata['rpc_blogid'], $this->userdata['rpc_user'], $this->userdata['rpc_pass'], new XML_RPC_Value($tempType, 'string'), new XML_RPC_Value($template, 'string'))); return Services_Blogging_XmlRpc::sendRequest($request, $this->rpc_client); }