开发者

How can I get a Post with XML-RPC in Wordpress?

开发者 https://www.devze.com 2023-01-04 08:19 出处:网络
After some digging around with the Wordpress XML-RPC documentation, it seems that there isn\'t a way to remotely obtain a \"post\" (such as a news article) through the XML-RPC interface.The documentat

After some digging around with the Wordpress XML-RPC documentation, it seems that there isn't a way to remotely obtain a "post" (such as a news article) through the XML-RPC interface. The documentation only mentions wp.getPage - if I try and pass in a PostID to this method, it returns:

 [faultCode] => 404 [faultString] => Sorry, no such page. 

... but wp.GetPage obviously does work when I pass a valid PageID. Does anyone have any ideas how I might go about solving this? Ideally, without extending the XML-RPC mechanism on the remote site (as access to these开发者_JAVA技巧 could be tricky)


I managed to figure this out. You can do this by using the "blogger.getPost" method. There isn't much documentation for this on the Wordpress site, but if you check out xmlrpc.php in the root of the Wordpress directory you will find a complete list of XML-RPC functions, including:

        // Blogger API
        'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
        'blogger.getUserInfo' => 'this:blogger_getUserInfo',
        'blogger.getPost' => 'this:blogger_getPost',
        'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
        'blogger.getTemplate' => 'this:blogger_getTemplate',
        'blogger.setTemplate' => 'this:blogger_setTemplate',
        'blogger.newPost' => 'this:blogger_newPost',
        'blogger.editPost' => 'this:blogger_editPost',
        'blogger.deletePost' => 'this:blogger_deletePost',

Hope this helps anyone who struggles with this in future.


See:

Wordpress XMLRPC API | Remote Control Wordpress


Check this site out. It explains the Blogger API, and the parameters that each method consumes:

http://xmlrpc.free-conversant.com/docs/bloggerAPI#newPost


I relocated elWpAPI to its own domain. And improved it a lot, including media uploads and full WordPress 3.2.1 compatibility of both the Core API and the rFC/rSQL plugin. Just saying... ;)

And the morally incompatible browser 'error' is gone. Failed forcing people into minimal privacy defense mode.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号