making flickr's "blog this" work with mephisto
marcus • September 7th, 2007
this article refers to mephisto edge release 2983
i noticed this afternoon that i wasn’t able to configure my new flickr account to accept this blog for its “blog this” feature. digging down into mephisto’s logs, i was able to get it working by adding only a couple of things in vendors/plugins/mephisto_xmlrpc ...
since i have no clue how to create a proper patch-file, i wrote a little step by step guide detailing the changes:
in backend_controller.rb add a new web-service description (because flickr identifies itself as blogger)
web_service(:blogger) { MetaWeblogService.new(self) }
in meta_weblog_api.rb add the missing getUsersBlogs method definition:
# get a list of blogs that a user can access
api_method :getUsersBlogs,
:expects => [ {:appkey => :string}, {:username => :string}, {:password => :string} ],
:returns => [[MetaWeblogStructs::Blog]]
create a new file struct /vender/plugins/mephisto_xmlrpc/meta_weblog_structs/blog.rb
module MetaWeblogStructs
class Blog < ActionWebService::Struct
member :blogName, :string
member :blogid, :string
member :url, :string
member :isAdmin, :boolean
end
end
and finally don’t forget to add the actual method implementation in meta_weblog_service.rb
def getUsersBlogs(appkey, username, password)
user = User.find_by_login(username)
return if user.nil?
blogs = Array.new
for site in user.sites
isAdmin = false
for membership in user.memberships
isAdmin = true if membership.site === site
end
blogs << MetaWeblogStructs::Blog.new(
:blogName => site.title,
:blogid => site.id,
:url => "http://#{site.host}",
:isAdmin => isAdmin
)
end
return blogs
end
You should be now able to add your mephisto blog as a “MetaWeblogAPI enabled Blog” to your flickr account and start posting!
