{"id":382,"date":"2003-05-09T09:37:50","date_gmt":"2003-05-09T13:37:50","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=382"},"modified":"2003-05-09T09:37:50","modified_gmt":"2003-05-09T13:37:50","slug":"apache-xml-rpc-metaweblog-api","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2003\/05\/09\/apache-xml-rpc-metaweblog-api\/","title":{"rendered":"apache xml-rpc metaWeblog api"},"content":{"rendered":"<p>Some irish guy wrote up a short <a href=\"http:\/\/www.dynamicobjects.com\/d2r\/archives\/001929.html\">blogging APIs mini how-to<\/a> yesterday.  Then <a href=\"http:\/\/www.phase2.tv\/\">some other guy<\/a> from England (I think) commented that he had written up a <a href=\"http:\/\/www.phase2.tv\/000093.html\">quick example of using the apache xml-rpc package to call the metaWeblog api<\/a>.  So I had to try it too.  Turns out that a) xml-rpc is really easy to do and b) the <a href=\"http:\/\/www.movabletype.org\/docs\/mtmanual_programmatic.html#xmlrpc%20api\">Moveable Type xml-rpc api<\/a> is really easy too&#8230; the code below calls the getRecentPosts() method of the metaWeblog api using the <a href=\"http:\/\/xml.apache.org\/dist\/xmlrpc\/\">apache xml-rpc<\/a> package:<\/p>\n<p>import org.apache.xmlrpc.*;<br \/>\nimport java.util.*;<br \/>\npublic class MTTest {<br \/>\n&nbsp;&nbsp;public static void main(String[] args) throws Exception {<\/p>\n<p>&nbsp;&nbsp;&nbsp;System.out.println(&#8220;Starting Movable type stuff&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp;Vector params=null;<\/p>\n<p>&nbsp;&nbsp;&nbsp;\/\/ Create XML RPC Client object<br \/>\n&nbsp;&nbsp;&nbsp;XmlRpcClient xmlrpc = new XmlRpcClient(&#8220;http:\/\/yourhost.com\/MT-2.21\/mt-xmlrpc.cgi&#8221;); <\/p>\n<p>&nbsp;&nbsp;&nbsp;\/\/ blogger.getRecentPosts<br \/>\n&nbsp;&nbsp;&nbsp;\/\/ String appkey, String blogid, String username, String password, int numberOfPosts<br \/>\n&nbsp;&nbsp;&nbsp;System.out.println(&#8220;Adding the parameters&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp;params = new Vector();<br \/>\n&nbsp;&nbsp;&nbsp;params.add(&#8220;your_weblog_id&#8221;); \/\/ weblog id<br \/>\n&nbsp;&nbsp;&nbsp;params.add(&#8220;yourusername&#8221;); \/\/ username<br \/>\n&nbsp;&nbsp;&nbsp;params.add(&#8220;yourpassword&#8221;); \/\/ password<br \/>\n&nbsp;&nbsp;&nbsp;params.add(&#8220;4&#8221;); \/\/ number of posts to retrieve&#8230;<\/p>\n<p>&nbsp;&nbsp;&nbsp;System.out.println(&#8220;Making the call&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp;Vector v  = (Vector)xmlrpc.execute(&#8220;metaWeblog.getRecentPosts&#8221;,params);<\/p>\n<p>&nbsp;&nbsp;&nbsp;System.out.println(&#8220;This call results in &#8221; + v.size() + &#8221; posts.&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp;System.out.println(&#8220;These are the results:&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;for (int i=0; i<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some irish guy wrote up a short blogging APIs mini how-to yesterday. Then some other guy from England (I think) commented that he had written up a quick example of using the apache xml-rpc package to call the metaWeblog api. So I had to try it too. Turns out that a) xml-rpc is really easy &hellip; <a href=\"https:\/\/cephas.net\/blog\/2003\/05\/09\/apache-xml-rpc-metaweblog-api\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">apache xml-rpc metaWeblog api<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/382"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=382"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/382\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}