XMLRPC: blogger.getTemplate

blogger.getTemplate is used to get the Template of the blog. It is part of the blogger API. WordPress XMLRPC also supports it. But we couldn’t make use of it in any way.

blogger.getTemplate takes five parameters

  1. appkey: ignored (pass some blank value)
  2. blogid
  3. username,
  4. password,
  5. template_type: It can take values main or archiveIndex

Let’s take a look at the program


/*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.getTemplate request which takes on six parameters
 appkey: ignored (pass some blank value)
function blogger_getTemplate($appkey,$blogid, $username, $password, $template_type) {
   global $BLOGURL;
   $request = xmlrpc_encode_request("blogger.getTemplate",
      array($appkey, $blogid, $username, $password, $template_type));
    /*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*/

$blogid =1;

$USERNAME = "admin";
$PASSWORD = "check";

$template_type = "main";
blogger_getTemplate($appkey, $blogid, $USERNAME, $PASSWORD, $template_type);
echo "n";

On executing the program
$ php blogger.getTemplate.php
<?xml version="1.0"?>

As you can see WordPress doesn’t do anything in this case


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