b2evolution PHP Cross Reference Blogging Systems

Source: /inc/xmlrpc/apis/_b2.api.php - 153 lines - 4751 bytes - Summary - Text - Print

Description: XML-RPC : B2 API b2evolution - {@link http://b2evolution.net/} Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   1  <?php
   2  /**
   3   * XML-RPC : B2 API
   4   *
   5   * b2evolution - {@link http://b2evolution.net/}
   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
   7   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   8   *
   9   * @see http://b2evolution.net/man/b2-api
  10   *
  11   * @package xmlsrv
  12   *
  13   * @version $Id: _b2.api.php 6136 2014-03-08 07:59:48Z manuel $
  14   */
  15  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  16  
  17  
  18  $b2newpost_doc='Adds a post, blogger-api like, +title +category +postdate';
  19  $b2newpost_sig = array(array($xmlrpcString, $xmlrpcString, $xmlrpcString, $xmlrpcString, $xmlrpcString, $xmlrpcString, $xmlrpcBoolean, $xmlrpcString, $xmlrpcString, $xmlrpcString));
  20  /**
  21   * b2.newPost. Adds a post, blogger-api like, +title +category +postdate.
  22   *
  23   * b2 API
  24   *
  25   * @param xmlrpcmsg XML-RPC Message
  26   *                    0 ?
  27   *                    1 ?
  28   *                    2 username (string): Login for a Blogger user who is member of the blog.
  29   *                    3 password (string): Password for said username.
  30   *                    4 content (string): The content of the post.
  31   *                    5 publish (boolean): If set to true, the post will be published immediately.
  32   *                    6 title (string): The title of the post.
  33   *                    7 category (string): The internal name of the category you want to post the post into.
  34   *                    8 date (string): This is the date that will be shown in the post, give "" for current date.
  35   * @return xmlrpcresp XML-RPC Response
  36   */
  37  function b2_newpost($m)
  38  {
  39      // CHECK LOGIN:
  40      /**
  41       * @var User
  42       */
  43      if( ! $current_User = & xmlrpcs_login( $m, 2, 3 ) )
  44      {    // Login failed, return (last) error:
  45          return xmlrpcs_resperror();
  46      }
  47  
  48      $publish  = $m->getParam(5);
  49      $publish = $publish->scalarval();
  50      $status = $publish ? 'published' : 'draft';
  51  
  52       $content = $m->getParam(4);
  53       $title = $m->getParam(6);
  54       $main_cat = $m->getParam(7);
  55       $date = $m->getParam(8);
  56  
  57      $params = array(
  58              'title'            => $title->scalarval(),
  59              'content'        => $content->scalarval(),
  60              'main_cat_ID'    => $main_cat->scalarval(),
  61              'date'            => $date->scalarval(),
  62              'status'        => $status,
  63          );
  64  
  65      // COMPLETE VALIDATION & INSERT:
  66      return xmlrpcs_new_item( $params );
  67  }
  68  
  69  
  70  
  71  
  72  $b2getcategories_doc='given a blogID, gives an array of structs that list categories in that blog, using categoryID and categoryName. categoryName is there so the user would choose a category name from the client, rather than just a number. however, when using b2.newPost, only the category ID number should be sent.';
  73  $b2getcategories_sig = array(array($xmlrpcArray, $xmlrpcString, $xmlrpcString, $xmlrpcString));
  74  /**
  75   * b2.getCategories
  76   *
  77   * Gets also used for mt.getCategoryList. Is this correct?
  78   *
  79   * @param xmlrpcmsg XML-RPC Message
  80   *                    0 blogid (string): Unique identifier of the blog to query
  81   *                    1 username (string): Login for a Blogger user who is member of the blog.
  82   *                    2 password (string): Password for said username.
  83   * @return xmlrpcresp XML-RPC Response
  84   */
  85  function b2_getcategories( $m )
  86  {
  87      return _b2_or_mt_get_categories('b2', $m);
  88  }
  89  
  90  
  91  
  92  
  93  $b2_getPostURL_doc = 'Given a blog ID, username, password, and a post ID, returns the URL to that post.';
  94  $b2_getPostURL_sig = array(array($xmlrpcString, $xmlrpcString, $xmlrpcString, $xmlrpcString, $xmlrpcString, $xmlrpcString));
  95  /**
  96   * b2.getPostURL
  97   *
  98   * @param xmlrpcmsg XML-RPC Message
  99   *                    0 ? NO LONGER USED (was: blogid (string): Unique identifier of the blog to query)
 100   *                    1 ? (string)
 101   *                    2 username (string): Login for a Blogger user who is member of the blog.
 102   *                    3 password (string): Password for said username.193
 103   *
 104   *                    4 post_ID (string): Post to query
 105   * @return xmlrpcresp XML-RPC Response
 106   */
 107  function b2_getposturl($m)
 108  {
 109      // CHECK LOGIN:
 110      /**
 111       * @var User
 112       */
 113      if( ! $current_User = & xmlrpcs_login( $m, 2, 3 ) )
 114      {    // Login failed, return (last) error:
 115          return xmlrpcs_resperror();
 116      }
 117  
 118      // GET POST:
 119      /**
 120       * @var Item
 121       */
 122      if( ! $edited_Item = & xmlrpcs_get_Item( $m, 4 ) )
 123      {    // Failed, return (last) error:
 124          return xmlrpcs_resperror();
 125      }
 126  
 127      // CHECK PERMISSION: (user needs to be able to view the item)
 128      if( ! xmlrpcs_can_view_item( $edited_Item, $User ) )
 129      {    // Permission denied
 130          return xmlrpcs_resperror( 3 );    // User error 3
 131      }
 132  
 133      logIO( 'OK.' );
 134      return new xmlrpcresp( new xmlrpcval( $edited_Item->get_permanent_url() ) );
 135  }
 136  
 137  
 138  $xmlrpc_procs['b2.newPost'] = array(
 139                  'function' => 'b2_newpost',
 140                  'signature' => $b2newpost_sig,
 141                  'docstring' => $b2newpost_doc );
 142  
 143  $xmlrpc_procs['b2.getCategories'] = array(
 144                  'function' => 'b2_getcategories',
 145                  'signature' => $b2getcategories_sig,
 146                  'docstring' => $b2getcategories_doc );
 147  
 148  $xmlrpc_procs['b2.getPostURL'] = array(
 149                  'function' => 'b2_getposturl',
 150                  'signature' => $b2_getPostURL_sig,
 151                  'docstring' => $b2_getPostURL_doc );
 152  
 153  ?>

title

Description

title

Description

title

Description

title

title

Body