Overview

Packages

  • Jyxo_Beholder
  • Jyxo_Charset
  • Jyxo_Color
  • Jyxo_Css
  • Jyxo_ErrorHandling
  • Jyxo_FirePhp
  • Jyxo_Gettext
    • Parser
  • Jyxo_Html
  • Jyxo_Input
    • Chain
    • Filter
    • Validator
  • Jyxo_Mail
    • Email
    • Parser
    • Sender
  • Jyxo_Rpc
    • Json
    • Xml
  • Jyxo_Shell
  • Jyxo_SpamFilter
  • Jyxo_Spl
  • Jyxo_String
  • Jyxo_Svn
  • Jyxo_Time
  • Jyxo_Timer
  • Jyxo_Webdav
  • Jyxo_XmlReader
  • PHP

Classes

  • Jyxo_Rpc_Xml_Client
  • Jyxo_Rpc_Xml_Server

Exceptions

  • Jyxo_Rpc_Xml_Exception
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * Jyxo PHP Library
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file license.txt.
10:  * It is also available through the world-wide-web at this URL:
11:  * https://github.com/jyxo/php/blob/master/license.txt
12:  */
13: 
14: /**
15:  * Class for sending requests using XML-RPC.
16:  * Requires xmlrpc and curl PHP extensions.
17:  *
18:  * @category Jyxo
19:  * @package Jyxo_Rpc
20:  * @subpackage Xml
21:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
22:  * @license https://github.com/jyxo/php/blob/master/license.txt
23:  * @author Jaroslav HanslĂ­k
24:  */
25: class Jyxo_Rpc_Xml_Client extends Jyxo_Rpc_Client
26: {
27:     /**
28:      * Creates a client instance and eventually sets server address.
29:      * Also defines default client settings.
30:      *
31:      * @param string $url Server address
32:      */
33:     public function __construct($url = '')
34:     {
35:         parent::__construct($url);
36: 
37:         $this->options = array(
38:             'output_type' => 'xml',
39:             'verbosity' => 'pretty',
40:             'escaping' => array('markup'),
41:             'version' => 'xmlrpc',
42:             'encoding' => 'utf-8'
43:         );
44:     }
45: 
46:     /**
47:      * Sends request and fetches server's response.
48:      *
49:      * @param string $method Method name
50:      * @param array $params Method parameters
51:      * @return mixed
52:      * @throws BadMethodCallException If no server address was provided
53:      * @throws Jyxo_Rpc_Xml_Exception On error
54:      */
55:     public function send($method, array $params)
56:     {
57:         // Start profiling
58:         $this->profileStart();
59: 
60:         try {
61:             // Fetch response
62:             $response = $this->process('text/xml', xmlrpc_encode_request($method, $params, $this->options));
63: 
64:             // Process response
65:             $response = xmlrpc_decode($response, 'utf-8');
66: 
67:         } catch (Jyxo_Rpc_Exception $e) {
68:             // Finish profiling
69:             $this->profileEnd('XML', $method, $params, $e->getMessage());
70: 
71:             throw new Jyxo_Rpc_Xml_Exception($e->getMessage(), 0, $e);
72:         }
73: 
74:         // Finish profiling
75:         $this->profileEnd('XML', $method, $params, $response);
76: 
77:         // Error in response
78:         if ((is_array($response)) && (isset($response['faultString']))) {
79:             throw new Jyxo_Rpc_Xml_Exception(preg_replace('~\s+~', ' ', $response['faultString']));
80:         }
81: 
82:         return $response;
83:     }
84: }
85: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0