I can’t work out how to do this. This is what I’ve tried but it doesn’t work. It adds the post but not the custom fields.
function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$categories=array(1)){
$categories = implode(",", $categories);
$XML = "<title>$title</title>".
"<category>$categories</category>".
$body;
$cflds = array('name' => 'a name', 'url' => 'https://www.google.com');
$content = array('post_type' => 'post', 'title' => $title, 'description' => $body, 'custom_fields' => $cflds);
$params = array('',$username,$password,$content,$XML,1);
$request = xmlrpc_encode_request('metaWeblog.newPost',$params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_exec($ch);
curl_close($ch);
echo '<pre>'.$request;
}