XMLRPC: blogger.editPost

With XMLRPC, you can blogfrom any Desktop clients like BloGTK. WordPress XMLRPC also supports blogger API. blogger.editPost helps you to edit the contents of a post

blogger.editPost takes six parameters

  1. appkey: ignored (pass some blank value)
  2. postid: the post to be edited,
  3. username,
  4. password,
  5. content,
  6. to publish or not

The following PHP program shows how to make use of the blogger.editPost


/*The URL of the blog*/
$BLOGURL = "http://localhost/wordpress";

function get_response($URL, $context) {
    if(!function_exists('curl_init')) {
    die ("Curl PHP package not installedn");
    /*Initializing CURL*/
    $curlHandle = curl_init();
    /*The URL to be downloaded is set*/
    curl_setopt($curlHandle, CURLOPT_URL, $URL);
    curl_setopt($curlHandle, CURLOPT_HEADER, false);
    curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
    curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $context);
    /*Now execute the CURL, download the URL specified*/
    $response = curl_exec($curlHandle);
    return $response;

/*Creating the blogger.editPost request which takes on six parameters
 appkey: ignored (pass some blank value)
 postid: the post to be edited,
 to publish or not*/
function blogger_editPost($appkey,$postid, $username, $password, $content, $toPublish) {
   global $BLOGURL;
   $request = xmlrpc_encode_request("blogger.editPost",
      array($appkey, $postid,$username, $password, $content ,$toPublish));
    /*Making the request to wordpress XMLRPC of your blog*/
    $xmlresponse = get_response($BLOGURL."/xmlrpc.php", $request);
    $response = xmlrpc_decode($xmlresponse);
    /*Printing the response on to the console*/


$USERNAME = "admin";
$PASSWORD = "check";
/*The id of the post to be edited*/
$postid = 6;
$title = "Sample Post Title";
/*The contents of your post (The new contents or the edited post)*/
$description = "This is the contents of the edited post.";
/*Whether the post has to be published, usually ignored*/
$toPublish = false;
blogger_editPost($appkey, $postid, $USERNAME, $PASSWORD, $description, $toPublish);
echo "n";

You can see that the variable $description contains the new contents (eidted)
Let’s execute this program with a non existing post

$ php blogger.editPost.php 
<?xml version="1.0"?>
          <value><string>Sorry, no such post.</string></value>

Now suppose, if Post ID was existent,

$ php blogger.editPost.php 
<?xml version="1.0"?>

The boolean value signifies that the

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s