Almost every standard compliant blogs support three blogging API which are “Blogger API” , “MovableType API” and “MetaWeblog API”. Among these three, MW (or MetaWeblog) is used more than other two. WordPress also supporst these three sets of API. If you are interesetd how to interact with these API’s – then take a look at the following example.
First lets discover which XMLRPC methods are suported by wordpress XMLRPC server. After digging a bit further we found that the following methods are supported
system.multicall
system.listMethods
system.getCapabilities
demo.addTwoNumbers
demo.sayHello
pingback.extensions.getPingbacks
pingback.ping
mt.publishPost
mt.getTrackbackPings
mt.supportedTextFilters
mt.supportedMethods
mt.setPostCategories
mt.getPostCategories
mt.getRecentPostTitles
mt.getCategoryList
metaWeblog.getUsersBlogs
metaWeblog.setTemplate
metaWeblog.getTemplate
metaWeblog.deletePost
metaWeblog.newMediaObject
metaWeblog.getCategories
metaWeblog.getRecentPosts
metaWeblog.getPost
metaWeblog.editPost
metaWeblog.newPost
blogger.deletePost
blogger.editPost
blogger.newPost
blogger.setTemplate
blogger.getTemplate
blogger.getRecentPosts
blogger.getPost
blogger.getUserInfo
blogger.getUsersBlogs
so to make a new post using metaWeblog.newPost method lets take a look at the following example.
<?php include("xmlrpc.inc.php"); $c = new xmlrpc_client("/wp/xmlrpc.php", "localhost", 80); $content['title']="XMLRPC Post"; $content['description']="Some content posted using MetaWeblog API"; $content['categories'] = array("frontpage"); $x = new xmlrpcmsg("metaWeblog.newPost", array(php_xmlrpc_encode("1"), php_xmlrpc_encode("admin"), php_xmlrpc_encode("root"), php_xmlrpc_encode($content), php_xmlrpc_encode("1"))); $c->return_type = 'phpvals'; $r =$c->send($x); if ($r->errno=="0") echo "Successfully Posted"; else { echo "There are some error"; print_r($r); } ?>
Thats it!!
how do we make http://www.somewhereinblog.net open source and/or get api’s that people can stick up on their websites, both initiating reading and writing from that window? can we discuss about that soon?
isnt somewhereinblog based on wordpress 2.0? It is already opensource and support metaweblog API. All you need to develop a web based GUI for them. Or create user ID for each of them and inform their user ID. They can implement access our blog using Blog APIs.
have you ever been to http://m.wordpress.com [For mobile] ? We could have something like that.
Hi,
where can I get ‘xmlrpc.inc.php’ and ‘/wp/xmlrpc.php’??
/wp/xmlrpc.php – is the same using by WordPress PHP Script??
To use this code I need xmlrpc_client CLASS, right??
I want to setup a simple PHP Script to load from RSS Feed and use MetaWeblog API to Post to some Blog.
I may use this Script????
Thanks in advance,
m.
@Mallcom
Yes you are right that you have to use an xml-rpc client. In the example shown above I used PHP XML-RPC package which is available from sourceforge at the following URL
http://phpxmlrpc.sourceforge.net/
You can use this script without any problem at all.
Regards
Hi,
I get no response using this
return_type = ‘phpvals’;
$r =$c->send($x);
if ($r->errno==”0″)
echo “Successfully Posted”;
else {
echo “There are some error”;
print_r($r);
}
?>
I’m using xmlrpc.inc.php found at lib folder at xmlrpc-2.1 zip.
Is it allright??
thanks in advance hasin.
m.
Hello
I am Prashant from calcutta India.
I need your help in wordpress.
I have integrated WordPress in my site and now from here anyone can create new WPblog. Its working fine.
If my site is mysite.com then after creating WPblog the new blog url is abc.mysite.com.
Problem :
Now i am trying to use XML-RPC 2.2 and trying to fetch blogger information, its working fine if i am trying to fetch blogs which is under wordpress.com (hosted by others) but i am not able to fetch the same for my site!! ( I have .htaccess in my mysite.com site and from there i am redirecting my user to there blogs.) . Will you please tell me what the mistake i am doing here.
Error : When i am trying to fetch the “abc.mysite.com” then i am getting “404 not found” ,when i am doing abc.mysite.com/xmlrpc.php i am getting the msg : “XML-RPC server accepts POST requests only.”
I show this error in many site but not getting the solution. i hope i will get help soon!!!
Thanks
Prashant
please trun on debug by writing $c->debug = true;
Then you can analyze what went wrong!
Thanks you Hasin. I was struggling with Blogger API as the title wasn’t getting set when posting to wordpress. The code stub you gave works wonderfully well. Still have problems with the categories though. Couldnt figure that out. If you can mail me how to set categories in these posts, that would be lovely. Thanks a lot !! Cheers!!
Hi, do you any code that can be used to run getCategories?
Hi Hasin,
thanks a lot for your example.
My question is: how do you get the allowed element lists to populate $content array (I mean … where is described the struct?)
thanks
Неплохой пост, но много лишнего.
По моему у Вас украли эту статью и поместили на другом сайте. Я её уже видела.
Спасибо за статью.. Актуально мне сейчас.. Взяла себе еще перечитать.
Уважаемый автор блога, а вы случайно не из Москвы?
У вас RSS в кривой кодировке!
Классно всё: и картинка ,и информация
Огромное человеческое спасбо!
Огромное вам человеческое спасибо, очень актуальная заметка.
а вот вопросик можно? У вас время после поста указано. Это московское? Заранее спасибо!
Неплохой пост, но много лишнего.
Спасибо за статью.. Актуально мне сейчас.. Взяла себе еще перечитать.
)))А у вас пара ошибок в тексте…)
Уважаемый автор блога, а вы случайно не из Москвы?
очень занимательно было почитать
Постебался, спасибо за ссылку 😉
Постебался, спасибо за ссылку 😉
очень занимательно было почитать
Скажите, а у вас есть RSS поток в этом блоге?
А у вас пара ошибок в тексте… тока не обижайтесь )
Спасибо огромное. Почитал и понравилось. Картинок бы ещё
Да уж Читаю и поинмаю, что ничего не понимаю о чем речь:)
Спасибо огромное. Почитал и понравилось. Картинок бы ещё
А я люблю Ниссан.
:))))) хорошо пишешь
This works great for my wordpress stuff, but I’m trying to figure out how to set the content such that it will schedule the post for a future date/time. Any ideas what I need to set in content?
интересно было бы с вами лично пообщаться )) вы в аське бываете? или в скайпе?…