Using Wordpress XML-RPC wp.uploadFile and wp.newPost from PHP
to post via xmlrpc i'm using IXR
require_once("IXR_Library.php.inc");
the below is what i'm using; it will need certainly some edits but might give you some clue
to upload a new file:
$file_upload_path = get_post_meta ( $image->ID,'_wp_attached_file', false);$file_path = $_SERVER['DOCUMENT_ROOT']."/dev/0.2/wp-content/uploads/".$file_upload_path[0];$path_parts = pathinfo($file_path);$file_name = $path_parts['filename'].'.'.$path_parts['extension'];$data = array( 'name' => $file_name , 'type' => $image->post_mime_type , 'bits' => new IXR_Base64( file_get_contents( $file_path ) ) , 'overwrite' => true);$status = $rpc->query( 'wp.uploadFile', '1', $username, $password, $data);$image_returnInfo = $rpc->getResponse();
to create a new post:
$data = array( 'post_title' => $post->post_title, 'post_content' => $post->post_content . $attachement_string_hack, 'post_type' => 'product', 'post_status' => 'publish', 'dateCreated' => (new IXR_Date(time())), 'post_thumbnail' => $image_returnInfo['id']);$rpc = new IXR_Client( $rpc_url );$res = $rpc->query('wp.newPost', '', $username, $password, $data, 0);
hope this helps!(i'm now stuck with attaching images to post)