This is jointly an xmlrpc question. I have a string of data coming in from a .wav file. I read the file in, with file_get_contents() then I have to submit that information to an xmlrpc server (which I did not create). It takes the .wav audio data in base64. I have tried using base64_encode(), but that also returns the “string” type. I thought that maybe This php guide on xmlrpc_set_type would help, but this returns an object containing an array that contains a base64 encoded string.
Is there a way to set the string that I am working with as type base64?
this is what I have so far, that is creating errors:
$data = base64_encode(file_get_contents('myfile.wav', NULL, NULL, 44));
$request = xmlrpc_encode_request('service',array('AudioData'=>$data));
I have tried this as well:
$data = file_get_contents('myfile.wav', NULL, NULL, 44);
$request = xmlrpc_encode_request('service',array('AudioData'=>xmlrpc_set_type($data, 'base64')));
This is the response I get:
["faultCode"]=> int(0) ["faultString"]=> string(155) "request contains string value where base64 expected
EDIT:
I am aware that base64 is not a type. Obviously the server I am using will not except a string of base64 encoded data, so my question is how to make that work.
The
xmlrpc_set_typefunction can be used to “mark” a value as being of a specific type (base64 or datetime) in a XML-RPC request. It returns a boolean indicating if the operation was successful.Basically, what happens is that the value is wrapped in a standard PHP class object along with its type and the variable passed as a reference to
xmlrpc_set_typeholds this object instead of the original raw value.When calling
xmlrpc_encode_request, the same variable previously passed as a reference toxmlrpc_set_typein order to declare the value type, should be embedded in a$paramsarray passed as second argument.Please note, these functions are still considered as experimental and should be used with much care.
Example: