Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.weblog.metaWeblogApi.rpcHandlers.getPost
on getPost (postid, username, password) {
<<Changes
<<12/21/02; 1:00:37 AM by JES
<<Only return elements whose size is non-zero. Works around a bug in Apple's XML-RPC implementation.
<<Details from Brent Simmons here: http://www.xmlrpc.com/discuss/msgReader$2380
<<11/20/02; 5:06:27 PM by JES
<<Entity-encode high-ascii characters in the post title and description, source name, and category names. Convert the description to Latin text when running on MacOS.
<<6/10/02; 7:31:33 PM by DW
<<The struct returned now includes a string called permaLink.
<<http://www.xmlrpc.com/metaWeblogApi#update61002RadioImplementationReturnsPermalink
<<6/10/02; 7:07:53 PM by DW
<<Return a new attribute, permaLink, which is the URL of the post.
<<3/13/02; 8:48:51 PM by DW
<<Created.
radio.weblog.bloggerApi.checkUser (client, false, username, password);
local (adrblog = radio.weblog.init ());
local (adrpost = @adrblog^.posts.[string.padwithzeros (postid, 8)]);
on encode (s) {
s = xml.entityEncode (s, false);
return (s)};
local (struct);
new (tabletype, @struct);
struct.userid = user.radio.prefs.usernum;
struct.postid = postid;
struct.dateCreated = adrpost^.when;
struct.description = string (adrpost^.text);
if system.environment.isMac { //convert to latin charset
struct.description = latinToMac.macToLatin (struct.description)};
struct.description = encode (struct.description);
try {radio.weblog.getUrlForPost (adrpost, @struct.permaLink, adrdata:adrblog)};
if defined (adrpost^.title) {
if sizeOf (adrpost^.title) > 0 {
struct.title = encode (string (adrpost^.title))}};
if defined (adrpost^.link) {
if sizeOf (adrpost^.link) > 0 {
struct.link = string (adrpost^.link)}};
if defined (adrpost^.enclosure) {
if sizeOf (adrpost^.enclosure.url) > 0 {
new (tabletype, @struct.enclosure);
struct.enclosure.length = adrpost^.enclosure.length;
struct.enclosure.type = adrpost^.enclosure.type;
struct.enclosure.url = adrpost^.enclosure.url}};
if defined (adrpost^.sourceName) {
if (sizeOf (adrpost^.sourceUrl) > 0) and (sizeOf (adrpost^.sourceName) > 0) {
new (tabletype, @struct.source);
struct.source.name = encode (adrpost^.sourceName);
struct.source.url = adrpost^.sourceUrl}};
if defined (adrpost^.categories) {
if sizeOf (adrpost^.categories) > 0 {
local (adr);
struct.categories = {};
for adr in @adrpost^.categories {
struct.categories = struct.categories + {encode (nameof (adr^))}}}};
return (struct)}
<<bundle //test code
<<local (client = "127.0.0.1")
<<scratchpad.struct = getpost (762, user.radio.prefs.security.remoteUsername, user.radio.prefs.security.remotePassword)
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.