Page 1 of 1

XMLRPC

Posted: Tue Aug 22, 2006 8:46 am
by my_raj_raj2
Hi,

I get the data from another site via xml format no database.

How to connect to that site and get the data(request and response type of xml).

Anybody know how to do this.

Thanking You.

Posted: Tue Aug 22, 2006 8:51 am
by feyd

Posted: Tue Aug 22, 2006 9:03 am
by my_raj_raj2
Hi

Thanks for your reply.

Request to the server only in xml format.

Can't use the file_get_contents function.

Posted: Tue Aug 22, 2006 9:08 am
by feyd
Then it's either fsockopen() or cURL.

Posted: Tue Aug 22, 2006 9:40 am
by my_raj_raj2
when i search in web I found this coding

Code: Select all

<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>
I run this coding but i got following error

Code: Select all

Fatal error: Class 'xmlrpc_client' not found in C:\AppServ\www\rpc\test1.php on line 12
Why it is appear?

Help me

Posted: Tue Aug 22, 2006 9:49 am
by feyd
There error says it doesn't exist. Why that is, I can't say. I'm not psychic. Psychotic, maybe, but definitely not psychic.

And please use the highlighting functionality we have provided:

Code: Select all

for instance..