Services_Blogging
[ class tree: Services_Blogging ] [ index: Services_Blogging ] [ all elements ]

Source for file XmlRpc.php

Documentation is available at XmlRpc.php

  1. <?php
  2. require_once 'Services/Blogging/Exception.php';
  3. require_once 'XML/RPC.php';
  4.  
  5. /**
  6. * XmlRpc helper methods for the blogging API
  7. *
  8. @category Services
  9. @package  Services_Blogging
  10. @author   Anant Narayanan <anant@php.net>
  11. @author   Christian Weiske <cweiske@php.net>
  12. @license  http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  13. @link     http://pear.php.net/package/Services_Blogging
  14. */
  15. {
  16.     /**
  17.     * The function that actually sends an XML-RPC request to the server, handles
  18.     * errors accordingly and returns the appropriately decoded data sent as response
  19.     * from the server.
  20.     *
  21.     * @param XML_RPC_Message $request An appropriately encoded XML-RPC message
  22.     *                                   that needs to be sent as a request to the
  23.     *                                   server.
  24.     * @param XML_RPC_Client  $client  The XML-RPC client as which the request
  25.     *                                   is to be sent.
  26.     *
  27.     * @return Array The appropriately decoded response sent by the server.
  28.     */
  29.     public static function sendRequest($request$client)
  30.     {
  31.         $response $client->send($request);
  32.         if (!$response{
  33.             throw new Services_Blogging_Exception(
  34.                 'XML-RPC communication error: ' $client->errstr
  35.             );
  36.         else if ($response->faultCode(!= 0{
  37.             throw new Services_Blogging_Exception(
  38.                 $response->faultString(),
  39.                 $response->faultCode()
  40.             );
  41.         }
  42.  
  43.         $value = XML_RPC_Decode($response->value());
  44.         if (!is_array($value|| !isset($value['faultCode'])) {
  45.             return $value;
  46.         else {
  47.             throw new Services_Blogging_Exception(
  48.                 $value['faultString']$value['faultCode']
  49.             );
  50.         }
  51.     }//public static function sendRequest($request, $client)
  52.  
  53. }//class Services_Blogging_XmlRpc
  54. ?>

Documentation generated on Mon, 11 Mar 2019 15:25:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.