I'm trying to create/update wordpress custom posts using xml-rpc. The post includes some serialized fields such as location data:
a:2:{s:3:"lat";s:2:"51";s:3:"lng";s:3:"-3.2";}
I'm using php xmlrpc_encode_request which is "experimental". If I send the serialized string then wordpress serializes it again and I end up with a serialized string:
s:46:"a:2:{s:3:"lat";s:2:"51";s:3:"lng";s:3:"-3.2";}";
and I haven't found any combination of arrays or objects that will parse to a valid wordpress serialized field.
Can anyone point me in the right direction? Is this a wordpress xml-rpc bug, an issue with xmlrpc_encode_request or just me being a numpty?
Thanks
Basically I'm doing this:
$content=array();
$custom_fields=array();
$gps=array("latitude"=>"$lat","longitude"=>"$lng");
//do something in here so that xmlrpc will encode the array correctly
$custom_fields[]=array("key"=>"_post_location", "value"=>$gps);
$content['post_title']="the title";
$content['post_status']='publish';
$content['post_content']="the content";
$content['custom_fields]=$custom_fields;
$request = xmlrpc_encode_request( "wp.newPost", array( 0, $username, $password, $content));
//then send request to xmlrpc.php
No matter how I try to encode, serialize or unserialize the custom field array $gps it does not get encoded by xmlrpc.php correctly. I either get a serialized string or an empty field.