Following is the simple XMLRPC example showing the usage.
<html>
<head>
<title>XML-RPC PHP Demo</title>
</head>
<body>
<h1>XML-RPC PHP Demo</h1>
<?php
include 'xmlrpc.inc';
// Make an object to represent our server.
$server = new xmlrpc_client('/api/sample.php',
'xmlrpc-c.sourceforge.net', 80);
// Send a message to the server.
$message = new xmlrpcmsg('sample.sumAndDifference',
array(new xmlrpcval(5, 'int'),
new xmlrpcval(3, 'int')));
$result = $server->send($message);
// Process the response.
if (!$result) {
print "<p>Could not connect to HTTP server.</p>";
} elseif ($result->faultCode()) {
print "<p>XML-RPC Fault #" . $result->faultCode() . ": " .
$result->faultString();
} else {
$struct = $result->value();
$sumval = $struct->structmem('sum');
$sum = $sumval->scalarval();
$differenceval = $struct->structmem('difference');
$difference = $differenceval->scalarval();
print "<p>Sum: " . htmlentities($sum) .
", Difference: " . htmlentities($difference) . "</p>";
}
?>
</body></html>
<head>
<title>XML-RPC PHP Demo</title>
</head>
<body>
<h1>XML-RPC PHP Demo</h1>
<?php
include 'xmlrpc.inc';
// Make an object to represent our server.
$server = new xmlrpc_client('/api/sample.php',
'xmlrpc-c.sourceforge.net', 80);
// Send a message to the server.
$message = new xmlrpcmsg('sample.sumAndDifference',
array(new xmlrpcval(5, 'int'),
new xmlrpcval(3, 'int')));
$result = $server->send($message);
// Process the response.
if (!$result) {
print "<p>Could not connect to HTTP server.</p>";
} elseif ($result->faultCode()) {
print "<p>XML-RPC Fault #" . $result->faultCode() . ": " .
$result->faultString();
} else {
$struct = $result->value();
$sumval = $struct->structmem('sum');
$sum = $sumval->scalarval();
$differenceval = $struct->structmem('difference');
$difference = $differenceval->scalarval();
print "<p>Sum: " . htmlentities($sum) .
", Difference: " . htmlentities($difference) . "</p>";
}
?>
</body></html>
Another posts included in "PHP"
| How to block a connection from the certain site ? (0) | 2008/01/14 |
| File downloading via HTTP (0) | 2008/01/21 |
| How to extract file name from given URL ? (0) | 2008/01/21 |
| How to upload attachments such as image by metaWeblog API ? (0) | 2008/01/07 |
| How to post blog content by metaweblog API ? (3) | 2008/01/02 |
| Posting to a Wordpress Blog Via XMLRPC Using Blogger API (1) | 2007/12/15 |
| foreach loop (0) | 2007/10/16 |
| Can PHP switch in strings ? (0) | 2007/10/16 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 05:01
moneyideas
-
Subject different money making ideas
2010/01/29 13:49
moneyideas
-
Subject different money making ideas
2010/01/31 16:43
moneyideas

Prev

Rss Feed