|
What this is
Other links
The source code
require 'xmlrpc/client'
require 'uri'
module Blog
class Cousagi
class BlogCousagiException < StandardError
end
def initialize(username, password,opt={})
@username = username
@password = password
server = opt['server'] || 'http://www.yomiusa.net/api/api.cgi'
server_uri = URI.parse(server)
path = server_uri.path
path << '?' << server_uri.query if server_uri.query
@client = XMLRPC::Client.new(server_uri.host, path, server_uri.port)
end
def getNewEntry
result = @client.call('cousagi.getNewEntry', @username, @password)
title = result['Title']
body = result['Body']
[title, body]
rescue XMLRPC::FaultException
raise BlogCousagiException.new($!.faultString)
end
def getNewPhrase
result = @client.call('cousagi.getNewPhrase', @username, @password)
result['Phrase']
rescue XMLRPC::FaultException
raise BlogCousagiException.new($!.faultString)
end
def getNewWhisper
result = @client.call('cousagi.getNewWhisper', @username, @password)
result['Whisper']
rescue XMLRPC::FaultException
raise BlogCousagiException.new($!.faultString)
end
def getNewHaiku
result = @client.call('cousagi.getNewHaiku', @username, @password)
result["Haiku"]
rescue XMLRPC::FaultException
raise BlogCousagiException.new($!.faultString)
end
end # Cousagi
end # Blog
if $0==__FILE__
username = ARGV.shift
password = ARGV.shift
cousagi = Blog::Cousagi.new(username, password)
puts '# getNewEntry'
title, body = cousagi.getNewEntry
puts "## title"
puts title
puts "## body"
puts body
puts '# getNewPhrase'
puts cousagi.getNewPhrase
puts '# getNewWhisperw'
puts cousagi.getNewWhisper
puts '# getNewHaiku'
puts cousagi.getNewHaiku
end
|
Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com