Пример #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
             if (!$categoryId1 && $name == 'categoryId') {
                 $categoryId1 = $value;
             } elseif (!$categoryId2 && $name == 'categoryId') {
                 $categoryId2 = $value;
             }
         }
         $context['text'] .= "</p>\n";
     }
 } else {
     $context['text'] .= $data;
 }
 // testing parsing capability
 $sample_message = 'title: ga bu zo meu' . "\n" . 'source: shadok' . "\n" . 'categories: foo, bar' . "\n" . "\n" . '<introduction>a dummy introduction at ' . date("F j, Y, g:i a") . '</introduction>hello' . "\n\n" . 'world' . "\n\n" . 'hello world again' . "\n\n" . 'this is to ensure that messages with multiple lines are processed correctly';
 // blogger.newPost
 $context['text'] .= Skin::build_block('blogger.newPost', 'title');
 $parameters = array('dummy_appkey', $blogid, $user_name, $user_password, $codec->encode($sample_message, 'string'), TRUE);
 $result = Call::invoke($url, 'blogger.newPost', $parameters, 'XML-RPC');
 $status = @$result[0];
 $data = @$result[1];
 // display call result
 if (!$status) {
     $context['text'] .= 'status: ' . $data;
 } elseif (is_array($data) && isset($data['faultString']) && $data['faultString']) {
     $context['text'] .= $data['faultString'];
 } elseif (is_array($data)) {
     $context['text'] .= '?? ';
     foreach ($data as $item) {
         $context['text'] .= "<p>" . $item . "</p>\n";
     }
 } else {
     $context['text'] .= '"' . $data . '"';