예제 #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
파일: blog_test.php 프로젝트: rair/yacs
             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 . '"';