<?php /** * command line test program * * usage: php.exe -q xml_rpc_codec_test.php <sample_file.xml> * * @author Bernard Paques * @reference * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License */ // load the adequate codec include_once 'codec.php'; include_once 'xml_rpc_codec.php'; $codec = new xml_rpc_Codec(); $values = $codec->encode('hello world', 'string'); //$values = array('hello world', $codec->encode('hello world', 'base64'), $codec->encode(time(), 'date')); //$values = array('faultCode' => 123, 'faultString' => 'hello world'); //$result = $codec->export_request('subject.action', $values); $result = $codec->export_response($values); // actual transmission except on a HEAD request if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') { return; } // parse has failed if (!$result[0]) { echo "Error: " . $result[1]; } else { echo $result[1] . "\n"; }
} else { $response = array('flerror' => 0, 'message' => 'Thanks for the ping'); } } break; default: $response = array('faultCode' => 1, 'faultString' => 'Do not know how to process ' . $parameters['methodName']); Logger::remember('services/ping.php: ping unsupported methodName', $parameters, 'debug'); } } // no response yet if (!isset($response)) { $response = array('faultCode' => 1, 'faultString' => 'no response'); } // build a XML snippet $result = $codec->export_response($response); $status = @$result[0]; $response = @$result[1]; // handle the output correctly render_raw('text/xml; charset=' . $context['charset']); // actual transmission except on a HEAD request if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') { echo $response; } // save the response if debug mode if (isset($context['debug_ping']) && $context['debug_ping'] == 'Y') { Logger::remember('services/ping.php: ping response', $response, 'debug'); } elseif (isset($context['debug_trackback']) && $context['debug_trackback'] == 'Y' && $parameters['methodName'] == 'pingback.ping') { Logger::remember('services/ping.php: ping response', $response, 'debug'); } // the post-processing hook