note 27981 modified in function.xmlrpc-set-type by didou
| From: | didou@php.net | Date: | Sat, 27 Sep 2003 13:24:07 +0000 |
| Subject: | note 27981 modified in function.xmlrpc-set-type by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57191@lists.php.net to get a copy of this message | ||
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).
--was--
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