Page 1 of 1
Trying to find the right way to use XML-RPC
Posted: Fri Jan 11, 2008 7:50 pm
by cacimar
Below is a ruby script I'm using to call the Joomla XML-RPC Blogger API.
All functions work except the call to blogger.newPost
It returns an error from Joomla: XMLRPC::FaultException: Post check failed
(Error generated from the logic in plgins/xmrpc/blogger.php line 215)
Any ideas on the problem or working examples of open code which successfully uses the xml-rpc blogger api?
require 'xmlrpc/client'
# Sets server to my site
server = XMLRPC::Client.new2('http://mysite.com/xmlrpc/index.php')
# function getUserInfo($appkey, $username, $password)
result = server.call('blogger.getUserInfo','unused_appkey','admin','password')
puts result
# function getRecentPosts($appkey, $blogid, $username, $password, $numposts)
result = server.call('blogger.getRecentPosts','unused_appkey','unused_blogid','admin','password',9)
puts result
# function newPost($appkey, $blogid, $username, $password, $content, $publish)
server.call('blogger.newPost','unused_appkey','unused_blogid','admin','password','Post This', true)
Re: Trying to find the right way to use XML-RPC
Posted: Fri Jan 11, 2008 8:02 pm
by AmyStephen
I do not know of anyone successfully using it. There have been many saying they want to use it.
To the best of my knowledge, it's not had much developer attention for a long time, nor do I believe it will have any before v 1.5 goes live.
In my opinion, this solution will need to come from our community.
Thanks!
Amy
Re: Trying to find the right way to use XML-RPC
Posted: Fri Jan 11, 2008 8:19 pm
by cacimar
I've seen some confusing messages from the recent threads on it. It seemed they said the Blogger API as existed worked in Joomla. Maybe I'll brave that other thread to clarify.
I'll be working on something next month and am trying to ramp up and check existing functionality to have a good base to start.
Re: Trying to find the right way to use XML-RPC
Posted: Fri Jan 11, 2008 8:37 pm
by AmyStephen
Almost two years ago,
Johan added Blogger API v 1 to Joomla! v 1.5. That's the pieces you are working with. It really should be updated to 2.0.
There is some code started on a
MetaWeblog API that there was just no time to finish. That might provide someone a place to start with that API.
Make certain to check the Extensions Directory, as well. There's a lot of interest, of course, in this area.
HTH,
Amy
Re: Trying to find the right way to use XML-RPC
Posted: Fri Jan 11, 2008 9:15 pm
by cacimar
Amy,
Thanks for your help. I'll look at the MetaWebBlog stuff.
After an afternoon cup of coffee, I discovered the Blogger API needed a
tag in the last parameter.
The following works
Code: Select all
# function newPost($appkey, $blogid, $username, $password, $content, $publish)
result = server.call('blogger.newPost','unused_appkey','unused_blogid','admin','password','<title>Test Title</test>This shows up in the body<strong>So does this in bold</strong>', false)
Re: Trying to find the right way to use XML-RPC
Posted: Fri Jan 11, 2008 11:48 pm
by AmyStephen
Does that completely resolve the problem, and now the Blogger API for xml-rpc is usable?
If so, let's get that patch moving into core.
Re: Trying to find the right way to use XML-RPC
Posted: Sat Jan 12, 2008 12:26 am
by cacimar
I only changed how I was using existing code. In other words, I was using Joomla wrong - but it is also undocumented.
No change to Joomla.
I'm going to tinker with it more and try to summarize what I've found. The initial problem I'm trying to solve is "documenting existing functionality." I'm interesting in expanding the functionality, but I need to figure where we are first.
I have a specific need I'll have to work towards first, which is massive importing from xml exported from another common program (deadlining in February) - but I honestly believe the functionality will require fleshing out something already existing and taking advantage of it, so hopefully I'll at least be able to document it for people to take advantage of. I get the impression people are really looking for a full implementation of a common API used by the many clients out there.
But, right now, as Joomla is, you can programatically:
-getRecentPosts
-newPost - post uncategorized messages
-getUserInfo
untested but things appear to be in order:
deletePost
editPost
getPost
I believe is irrelevant:
getUserBlogs
Re: Trying to find the right way to use XML-RPC
Posted: Sat Jan 12, 2008 12:47 am
by AmyStephen
That is great! Anything you can shout out on that topic, from time to time will be appreciated. I hope others interested might also join in and you could learn from one another.
Good stuff. Appreciate it very much.
Amy
Re: Trying to find the right way to use XML-RPC
Posted: Tue Jan 15, 2008 7:30 pm
by cacimar
Below is a list of the functions and working ruby examples. Some comments included. Some more work to be done
Code: Select all
require 'xmlrpc/client'
# Sets server to my site
server = XMLRPC::Client.new2('http://joomla.drapetomanics.com/xmlrpc/index.php')
## function getUserBlogs($appkey, $username, $password)
## Errors out - irrelevant
# result = server.call('blogger.getUserBlogs','unused_appkey','admin','password')
# puts result
## function getUserInfo($appkey, $username, $password)
result = server.call('blogger.getUserInfo','unused_appkey','admin','password')
puts result
## function getPost($appkey, $postid, $username, $password)
result = server.call('blogger.getPost','unused_appkey','1','admin','password')
puts result
## function editPost($appkey, $postid, $username, $password, $content, $publish)
result = server.call('blogger.editPost','unused_appkey','2','admin','password','<titel>new content</title>content',true)
puts result
## XMLRPC::FaultException: Post check failed 2
## function deletePost($appkey, $postid, $username, $password, $publish)
result = server.call('blogger.deletePost','unused_appkey','1','admin','password',false)
puts result
#Missing return value initially
#no post afterwards
## function getRecentPosts($appkey, $blogid, $username, $password, $numposts)
result = server.call('blogger.getRecentPosts','unused_appkey','unused_blogid','admin','password',9)
puts result
## function getTemplate($appkey, $blogid, $username, $password, $templateType)
## not implemented
## function newPost($appkey, $blogid, $username, $password, $content, $publish)
result = server.call('blogger.newPost','unused_appkey','unused_blogid','admin','password','<title>Test Title4</title>test body<strong>bold</strong>', false)
puts result
Re: Trying to find the right way to use XML-RPC
Posted: Wed Jan 16, 2008 3:02 pm
by aini
Great, cacimar !!
I would love to add some optional things in postNews function
result = server.call('blogger.newPost','unused_appkey','unused_blogid','admin','password','
Test Title4The CMStest body
boldmore and more ', false)
puts result
You can see all this stuff in joomladir/plugins/xmlrpc/blogger.php
Re: Trying to find the right way to use XML-RPC
Posted: Wed Jan 16, 2008 3:08 pm
by cacimar
Aini,
When I tested the newPost before - and< more text>didn't seem to work.. The information seemed to go nowhere.. I haven't traced down the functionality there yet.
Re: Trying to find the right way to use XML-RPC
Posted: Thu Jan 17, 2008 4:28 am
by aini
could you attach your ruby code project ?
I will check it ...
Re: Trying to find the right way to use XML-RPC
Posted: Thu Jan 17, 2008 5:23 am
by AmyStephen
Rich -
You really lucked out. You have a core developer paying attention to your project. I guess you show a little promise!
Thanks, Aini!
Amy
Re: Trying to find the right way to use XML-RPC
Posted: Mon Jan 21, 2008 4:58 pm
by cacimar
aini,
I've attached my basic ruby testing script.
The very last call is the attempt to post. seems to go nowhere and doesn't appear to affect the category or section the new article is assigned to.
I mentioned earlier in the thread, I'm working on this now only in the background, but in early February I'll be working on it more with the hopes of transforming archived xml data (from Adobe inDesign) to a format useable by Joomla and posting it.
Re: Trying to find the right way to use XML-RPC
Posted: Wed Jan 23, 2008 1:57 pm
by aini
Hi Rich,
Well, I fully understand
It was Joomla bugs
I will fix the bug tomorrow
It sounds you have been working interesting stuff
Thanks in advance
Re: Trying to find the right way to use XML-RPC
Posted: Wed Jan 23, 2008 2:48 pm
by cacimar
Thanks Aini,
Maybe after I see your changes, I'll be able to see enough to contribute more to that area as well.
Re: Trying to find the right way to use XML-RPC
Posted: Thu Jan 24, 2008 3:52 am
by aini
I have put the patch in Joomla Tracker
http://joomlacode.org/gf/project/joomla ... em_id=9399Waiting Q&T to check it
Here is my following patch, You can test it in your PC
Code: Select all
Index: /data1/trunk/plugins/xmlrpc/blogger.php
===================================================================
--- /data1/trunk/plugins/xmlrpc/blogger.php (revision 9962)
+++ /data1/trunk/plugins/xmlrpc/blogger.php (working copy)
@@ -428,8 +428,9 @@
$match = array();
if ( preg_match('/<more_text>(.+?)<\/more_text>/is', $content, $match) )
{
- $fulltext = trim($match[1], ',');
- $fulltext = explode(',', $fulltext);
+ $fulltext = $match[0];
+ $fulltext = preg_replace('/<more_text>/si', '', $fulltext);
+ $fulltext = preg_replace('/<\/more_text>/si', '', $fulltext);
}
return $fulltext;
Anyway, for category tag, it is configured by default at blogger plugin configuration
You can see this following code :
Code: Select all
// load the category
$cat =& JTable::getInstance('category');
$cat->load($params->get( 'catid', 1 ));
I will ask in J!Dev List whether we could define any category through XML-RPC
That would be more nice