3

I have this blog post on my blog:

http://lifepearls.herobo.com/2011/06/tom-hardy-is-bane/

I make posts from my php code with this:

function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$category,$keywords='',$encoding='UTF-8') {
    $title = htmlentities($title,ENT_NOQUOTES,$encoding);
    $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);

    $content = array(
        'title'=>$title,
        'description'=>$body,
        'mt_allow_comments'=>0,  // 1 to allow comments
        'mt_allow_pings'=>0,  // 1 to allow trackbacks
        'post_type'=>'post',
        'mt_keywords'=>$keywords,
        'categories'=>array($category)
    );
    $params = array(0,$username,$password,$content,true);
    $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);
    $results = curl_exec($ch);
    curl_close($ch);
    return $results;

}

However, I dont know how to add the image, and what field.

Here is the image from the dashboard for the image:

http://lifepearls.herobo.com/path.jpg

This is the manual way to add my image to the post, since it is a part of the specific template.

How do I add my image remotely, any idea?

mhitza
  • 5,709
  • 2
  • 29
  • 52
mirzahat
  • 1,025
  • 2
  • 10
  • 19
  • if you have FTP access to the site, you could upload the image, then make use of this plugin to automatically create the media item. http://wordpress.org/extend/plugins/auto-post-images-api/. in fact, you could probably look at the shortcode action to see how that plugin works for a better idea – smcphill Jun 23 '11 at 17:36

2 Answers2

1

We've created a plugin ( WP Remote Connections ) that can send posts, pages, and media from one WordPress installation to one or many other WordPress :) It might be what you are looking for.

0

The MetaWebLog API has no ways to transmit images or other resources. You're lost, except you transfer the images via ftp/sftp and just <img>-include them.

cweiske
  • 30,033
  • 14
  • 133
  • 194