note 27981 added to function.xmlrpc-set-type
| From: | kelly at seankelly dot biz | Date: | Sat, 28 Dec 2002 13:53:26 +0000 |
| Subject: | note 27981 added to function.xmlrpc-set-type | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41379@lists.php.net to get a copy of this message | ||
As xmlrpc_set_type returns bool, the above example doesn't do anything useful (with due
respect, hfuecks).
The problem is that PHP has a string type which is also used to hold binary data and dates. But
XML-RPC defines three separate types for strings, binary data, and dates. How do you tell how you
want strings encoded? That's where this function comes in.
Suppose the XML-RPC method "log.data" took a string, a date, and a binary object. To tell
XML-RPC that the date (which is a PHP string) is a really a date and that the binary data (which is
also a PHP string) is really binary data, try:
$string = "My logging event.";
$date = "20030115T12:22:37"; // Must be this format
$binary = fread($fp, 128);
xmlrpc_set_type(&$date, "datetime");
xmlrpc_set_type(&$binary, "base64");
$xmlrpcReq = xmlrpc_encode_request("log.data", array($string, $date, $binary));
Note the reference passing in the calls to xmlrpc_set_type; that enables the function to change the
values from strings into what xmlrpc_encode/_request expects (which are objects that include a bonus
field that tells the desired XML-RPC type).
--
http://www.php.net/manual/en/function.xmlrpc-set-type.php
http://master.php.net/manage/user-notes.php?action=edit+27981
http://master.php.net/manage/user-notes.php?action=delete+27981
http://master.php.net/manage/user-notes.php?action=reject+27981