XMLRPC: blogger.getUsersBlogs

blogger.getUsersBlogs can be used to get the blogs of the User. It takes the following parameters

  1. appkey: ignored (pass some blank value)
  2. username,
  3. password,

The program is something like this


/*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.getUsersBlogs request which takes on following parameters
 appkey: ignored (pass some blank value)
function blogger_getUsersBlogs($appkey, $username, $password) {
   global $BLOGURL;
   $request = xmlrpc_encode_request("blogger.getUsersBlogs",
      array($appkey, $username, $password));
    /*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";
blogger_getUsersBlogs($appkey, $USERNAME, $PASSWORD);
echo "n";

On executing
$ php blogger.getUsersBlogs.php

<?xml version="1.0"?>
<member><name>blogName</name><value><string>Localhost Blog</string></value></member>


It returns various information like whether the user is an admin of the blog, the URL of the blog owned, the blog name

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