示例#1
0
<?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";
}
示例#2
0
文件: ping.php 项目: rair/yacs
include_once '../links/links.php';
include_once '../servers/servers.php';
// load a skin engine
load_skin('services');
// process raw content
$raw_data = file_get_contents("php://input");
// save the raw request if debug mode
if (isset($context['debug_ping']) && $context['debug_ping'] == 'Y') {
    Logger::remember('services/ping.php: ping request', $raw_data, 'debug');
}
// transcode to our internal charset
if ($context['charset'] == 'utf-8') {
    $raw_data = utf8::encode($raw_data);
}
// load the adequate codec
$codec = new xml_rpc_Codec();
// parse xml parameters
$result = $codec->import_request($raw_data);
$status = @$result[0];
$parameters = @$result[1];
// nothing to parse
if (!$raw_data) {
    $response = array('faultCode' => 5, 'faultString' => 'Empty request, please retry');
    // parse has failed
} elseif (!$status) {
    $response = array('faultCode' => 5, 'faultString' => 'Impossible to parse parameters');
    // dispatch the request
} else {
    // remember parameters if debug mode
    if (isset($context['debug_ping']) && $context['debug_ping'] == 'Y') {
        Logger::remember('services/ping.php: ping ' . $parameters['methodName'], $parameters['params'], 'debug');
示例#3
0
文件: blog_test.php 项目: rair/yacs
 *
 * This script checks the blog API
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 *
 * @see services/blog.php
 */
include_once '../shared/global.php';
include_once 'call.php';
// load the adequate codec
include_once 'codec.php';
include_once 'xml_rpc_codec.php';
$codec = new xml_rpc_Codec();
// load localized strings
i18n::bind('services');
// load the skin
load_skin('services');
// the title of the page
$context['page_title'] = i18n::s('Sample blog client');
// make a target
$target = '';
if (isset($_REQUEST['target'])) {
    $target = $_REQUEST['target'];
} elseif (isset($context['host_name'])) {
    $target = $context['host_name'] . rtrim($context['url_to_root'], '/');
}
$user_name = isset($_REQUEST['user_name']) ? $_REQUEST['user_name'] : '';
$user_password = isset($_REQUEST['user_password']) ? $_REQUEST['user_password'] : '';
示例#4
0
<?php

/**
 * command line test program
 *
 * usage: php.exe -q xml_rpc_codec_test.php <sample_file.xml>
 *
 * @author Bernard Paques
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 * @reference
 */
include_once '../shared/logger.php';
// load the adequate codec
include_once 'codec.php';
include_once 'xml_rpc_codec.php';
$codec = new xml_rpc_Codec();
// load some xml
//$xml = Safe::file_get_contents('xml-rpc/blogger.getUserInfo.request.xml');
//$xml = Safe::file_get_contents('xml-rpc/blogger.getUserInfo.response.xml');
//$xml = Safe::file_get_contents('xml-rpc/blogger.newPost.fault.xml');
//$xml = Safe::file_get_contents('xml-rpc/blogger.newPost.request.xml');
//$xml = Safe::file_get_contents('xml-rpc/blogger.newPost.response.xml');
//$xml = Safe::file_get_contents('xml-rpc/blogger.getUsersBlogs.request.xml');
//$xml = Safe::file_get_contents('xml-rpc/blogger.getUsersBlogs.response.xml');
//$xml = Safe::file_get_contents('xml-rpc/blogger.getUsersBlogs.response.2.xml');
//$xml = Safe::file_get_contents('xml-rpc/metaWeblog.newPost.request.xml');
$xml = Safe::file_get_contents('xml-rpc/metaWeblog.newPost.request.2.xml');
//$xml = Safe::file_get_contents('xml-rpc/getTemplate.response.xml');
//echo "Request:\n".$xml."\n";
if (!trim($xml)) {
    return;