示例#1
0
 /**
  * Change the current debug mode
  *
  * @param int $debug where 1 = on, 0 = off
  */
 public function setDebug($debug)
 {
     $this->client->setDebug($debug);
 }
<body>
<h1>Getstatename demo</h1>

<h2>Send a U.S. state number to the server and get back the state name</h2>

<h3>The code demonstrates usage of automatic encoding/decoding of php variables into xmlrpc values</h3>
<?php 
include_once __DIR__ . "/../../src/Autoloader.php";
PhpXmlRpc\Autoloader::register();
if (isset($_POST["stateno"]) && $_POST["stateno"] != "") {
    $stateNo = (int) $_POST["stateno"];
    $encoder = new PhpXmlRpc\Encoder();
    $req = new PhpXmlRpc\Request('examples.getStateName', array($encoder->encode($stateNo)));
    print "Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . "\n\n</pre>Debug info of server data follows...\n\n";
    $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php");
    $client->setDebug(1);
    $r = $client->send($req);
    if (!$r->faultCode()) {
        $v = $r->value();
        print "<br/>State number <b>" . $stateNo . "</b> is <b>" . htmlspecialchars($encoder->decode($v)) . "</b><br/>";
    } else {
        print "An error occurred: ";
        print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
    }
} else {
    $stateNo = "";
}
print "<form action=\"getstatename.php\" method=\"POST\">\n<input name=\"stateno\" value=\"" . $stateNo . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form>\n<p>Enter a state number to query its name</p>";
?>
</body>
</html>
示例#3
0
<p>This form enables you to send mail via an XML-RPC server.
    When you press <kbd>Send</kbd> this page will reload, showing you the XML-RPC request sent to the host server, the
    XML-RPC response received and the internal evaluation done by the PHP implementation.</p>

<p>You can find the source to this page here: <a href="mail.php?showSource=1">mail.php</a><br/>
    And the source to a functionally identical mail-by-XML-RPC server in the file <a
        href="../server/server.php?showSource=1">server.php</a> included with the library (look for the 'mail_send'
    method)</p>
<?php 
include_once __DIR__ . "/../../src/Autoloader.php";
PhpXmlRpc\Autoloader::register();
if (isset($_POST["mailto"]) && $_POST["mailto"]) {
    $server = "http://phpxmlrpc.sourceforge.net/server.php";
    $req = new PhpXmlRpc\Request('mail.send', array(new PhpXmlRpc\Value($_POST["mailto"]), new PhpXmlRpc\Value($_POST["mailsub"]), new PhpXmlRpc\Value($_POST["mailmsg"]), new PhpXmlRpc\Value($_POST["mailfrom"]), new PhpXmlRpc\Value($_POST["mailcc"]), new PhpXmlRpc\Value($_POST["mailbcc"]), new PhpXmlRpc\Value("text/plain")));
    $client = new PhpXmlRpc\Client($server);
    $client->setDebug(2);
    $resp = $client->send($req);
    if (!$resp->faultCode()) {
        print "Mail sent OK<br/>\n";
    } else {
        print "<fonr color=\"red\">";
        print "Mail send failed<br/>\n";
        print "Fault: ";
        print "Code: " . htmlspecialchars($resp->faultCode()) . " Reason: '" . htmlspecialchars($resp->faultString()) . "'<br/>";
        print "</font><br/>";
    }
}
?>
<form method="POST">
    From <input size="60" name="mailfrom" value=""/><br/>
    <hr/>