|
Posted by Mike P2 on 05/10/07 22:42
On May 10, 4:47 pm, Ming <minghu...@gmail.com> wrote:
> for the following code, why it uses $method = 'examples.getStateName';
> instead of $method = 'getStateName'; or $method =
> 'examples.getStateName()'
>
> What does "example" here mean? Thanks
>
> $method = 'examples.getStateName';
> $args = array(32); // data to be passed
> $request = compact('host', 'port', 'uri', 'method', 'args');
> $result = xu_rpc_http_concise($request);
It means the getStateName function is a method of the 'examples'
object. You don't need to put parenthesis on the end of the method
because there are never any arguments to put in there. The arguments
in an xml-rpc request go in the 'args' index of the array you pass to
xu_rpc_http_concise(). The whole thing with the compact() call
basically does the same thing as this:
<?php
xu_rpc_http_concise(
array(
'method' => 'examples.getStateName',
'args' => array( 32 ),
'host' => '...',
'port' => '...',
'uri' => '...'
)
)
?>
....because xu_rpc_http_concise() takes an associative array of it's
arguments instead of just the arguments in the parenthesis on the
function. What the example would look like if you were calling the
same method if it were right in PHP would be something like:
<?php
$examples = new SomeClass();
$result = $examples->getStateName( 32 );
echo "I love $result!\n";
?>
Where SomeClass is some class that has a getStateName() method that
does whatever the xml-rpc method does.
-Mike PII
Navigation:
[Reply to this message]
|