Class: BlogRPC::SampleHandler

Inherits:
BasicHandler
  • Object
show all
Defined in:
lib/blogrpc/sample_handler.rb

Overview

A sample MetaWeblog RPC handler. Bear in mind that you will need to rewrite most of it.

Define the standard methods for MetaWeblog API here. If you have a valiation problem or somesuch within the method just raise from there, exceptions will be translated into RPC fault codes.

You will need to take a look at (and override) get_entry and friends to retrofit that to your own engine.

Entry struct

A fundamental unit of the MT/MW API is the Entry struct (a Hash). Return that Hash anytime an entry struct is required. Here a short intro on the fields of the struct (you can use both symbols and strings for keys):

title, for the title of the entry;
description, for the body of the entry;
dateCreated, to set the created-on date of the entry;
In addition, Movable Type’s implementation allows you to pass in values for five other keys:
int mt_allow_comments, the value for the allow_comments field;
int mt_allow_pings, the value for the allow_pings field;
String mt_convert_breaks, the value for the convert_breaks field;
String mt_text_more, the value for the additional entry text;
String mt_excerpt, the value for the excerpt field;
String mt_keywords, the value for the keywords field;
String mt_basename, the value for the slug field;
array mt_tb_ping_urls, the list of TrackBack ping URLs for this entry;

If specified, dateCreated should be in ISO.8601 format. Also note that most blogging clients will have BIG issues if you supply non-UTC timestamps, so if you are using ActiveRecord timezone support (and you should!) take care to do all of your RPC operations with all timezones switched to UTC.

Constant Summary collapse

STRUCT_TO_ENTRY =

An example mapping for the XMLRPC fieldnames to ActiveRecord fields.

{
  "title" => "title", 
  "description" => "body",
  "dateCreated" => "created_at",
  "mt_text_more" => "more",
  "mt_basename" => "slug",
  "mt_allow_comments" => "allow_comments",
  "permalink" => "permalink",
  "link" => "permalink",
  "postId" => "id"
}
STRUCT_TO_CATEGORY =
{
  "categoryId" => "id",
  "categoryName" => "title",
}

Instance Attribute Summary

Attributes inherited from BasicHandler

#env

Method Summary

Methods inherited from BasicHandler

#get_methods, #handle_request, #initialize, rpc, rpc_methods_and_signatures

Constructor Details

This class inherits a constructor from BlogRPC::BasicHandler