/** * mt.getPostCategories : Get the categories for a given post. * * @param xmlrpcmsg XML-RPC Message * 0 postid (string): Unique identifier of the post to query * 1 username (string): Login for a Blogger user who is member of the blog. * 2 password (string): Password for said username. */ function mt_getPostCategories($m) { global $DB; // CHECK LOGIN: /** * @var User */ if (!($current_User =& xmlrpcs_login($m, 1, 2))) { // Login failed, return (last) error: return xmlrpcs_resperror(); } // GET POST: /** * @var Item */ if (!($edited_Item =& xmlrpcs_get_Item($m, 0))) { // Failed, return (last) error: return xmlrpcs_resperror(); } // CHECK PERMISSION (user needs to be able to view the post): if (!xmlrpcs_can_view_item($edited_Item, $current_User)) { // Permission denied return xmlrpcs_resperror(3); // User error 3 } // Tblue> TODO: We could save one DB query by using our own custom query // instead of postcats_get_byID(). $categories = postcats_get_byID($edited_Item->ID); // Secondary categories $iSize = count($categories); // The number of objects ie categories logIO('mt_getPostCategories no. of categories... ' . $iSize); // works $struct = array(); for ($i = 0; $i < $iSize; $i++) { logIO('mt_getPostCategories categories ...' . $categories[$i]); // In database cat_ID and cat_name from tablecategories $sql = 'SELECT * FROM T_categories WHERE cat_ID = ' . $categories[$i]; logIO('mt_getPostCategories sql...' . $sql); $rows = $DB->get_results($sql); foreach ($rows as $row) { $Categoryname = $row->cat_name; logIO('mt_getPostCategories Categoryname ...' . $Categoryname); } // Is this the primary cat? $isPrimary = $categories[$i] == $edited_Item->main_cat_ID ? 1 : 0; $struct[$i] = new xmlrpcval(array('categoryId' => new xmlrpcval($categories[$i]), 'categoryName' => new xmlrpcval($Categoryname), 'isPrimary' => new xmlrpcval($isPrimary, 'boolean')), 'struct'); } logIO('OK.'); return new xmlrpcresp(new xmlrpcval($struct, 'array')); }
/** * b2.getPostURL * * @param xmlrpcmsg XML-RPC Message * 0 ? NO LONGER USED (was: blogid (string): Unique identifier of the blog to query) * 1 ? (string) * 2 username (string): Login for a Blogger user who is member of the blog. * 3 password (string): Password for said username.193 * * 4 post_ID (string): Post to query * @return xmlrpcresp XML-RPC Response */ function b2_getposturl($m) { // CHECK LOGIN: /** * @var User */ if (!($current_User =& xmlrpcs_login($m, 2, 3))) { // Login failed, return (last) error: return xmlrpcs_resperror(); } // GET POST: /** * @var Item */ if (!($edited_Item =& xmlrpcs_get_Item($m, 4))) { // Failed, return (last) error: return xmlrpcs_resperror(); } // CHECK PERMISSION: (user needs to be able to view the item) if (!xmlrpcs_can_view_item($edited_Item, $User)) { // Permission denied return xmlrpcs_resperror(3); // User error 3 } logIO('OK.'); return new xmlrpcresp(new xmlrpcval($edited_Item->get_permanent_url())); }
/** * blogger.getPost retieves a given post. * * This API call is not documented on * {@link http://www.blogger.com/developers/api/1_docs/} * @see http://www.sixapart.com/developers/xmlrpc/blogger_api/bloggergetpost.html * * @param xmlrpcmsg XML-RPC Message * 0 appkey (string): Unique identifier/passcode of the application sending the post. * (See access info {@link http://www.blogger.com/developers/api/1_docs/#access} .) * 1 postid (string): Unique identifier of the post to be deleted. * 2 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). * 3 password (string): Password for said username. * @return xmlrpcresp XML-RPC Response */ function blogger_getpost($m) { // CHECK LOGIN: /** * @var User */ if (!($current_User =& xmlrpcs_login($m, 2, 3))) { // Login failed, return (last) error: return xmlrpcs_resperror(); } // GET POST: /** * @var Item */ if (!($edited_Item =& xmlrpcs_get_Item($m, 1))) { // Failed, return (last) error: return xmlrpcs_resperror(); } // CHECK PERMISSION: if (!xmlrpcs_can_view_item($edited_Item, $current_User)) { return xmlrpcs_resperror(3); } logIO('Permission granted.'); $post_date = mysql2date('U', $edited_Item->issue_date); $post_date = gmdate('Ymd', $post_date) . 'T' . gmdate('H:i:s', $post_date); $content = '<title>' . $edited_Item->title . '</title>'; $content .= '<category>' . $edited_Item->main_cat_ID . '</category>'; $content .= $edited_Item->content; $struct = new xmlrpcval(array('userid' => new xmlrpcval($edited_Item->creator_user_ID), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'content' => new xmlrpcval($content), 'postid' => new xmlrpcval($edited_Item->ID)), 'struct'); logIO('OK.'); return new xmlrpcresp($struct); }
/** * metaWeblog.getPost retieves a given post. * * @see http://www.xmlrpc.com/metaWeblogApi#basicEntrypoints * * @param xmlrpcmsg XML-RPC Message * 0 postid (string): Unique identifier of the post * 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. * @return xmlrpcresp XML-RPC Response */ function mw_getpost($m) { // CHECK LOGIN: /** * @var User */ if (!($current_User =& xmlrpcs_login($m, 1, 2))) { // Login failed, return (last) error: return xmlrpcs_resperror(); } // GET POST: /** * @var Item */ if (!($edited_Item =& xmlrpcs_get_Item($m, 0))) { // Failed, return (last) error: return xmlrpcs_resperror(); } // CHECK PERMISSION: if (!xmlrpcs_can_view_item($edited_Item, $current_User)) { // Permission denied return xmlrpcs_resperror(3); // User error 3 } $item = _wp_mw_get_item_struct($edited_Item); logIO('OK.'); return new xmlrpcresp(new xmlrpcval($item, 'struct')); }