XMLRPC

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
my_raj_raj2
Forum Commoner
Posts: 28
Joined: Mon Mar 20, 2006 8:06 am
Location: India

XMLRPC

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

my_raj_raj2
Forum Commoner
Posts: 28
Joined: Mon Mar 20, 2006 8:06 am
Location: India

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Then it's either fsockopen() or cURL.
my_raj_raj2
Forum Commoner
Posts: 28
Joined: Mon Mar 20, 2006 8:06 am
Location: India

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
Post Reply