使用 XML-RPC 阅读 WordPress 博客
无论我在哪里寻找,我都找不到将我的应用程序完全连接到 Wordpress 的方法。我想做的是:在您未登录时显示最近的文章(当然是已发布的)和较早的文章,并方便为登录的用户撰写评论。
看起来我必须从 RSS 中提取博客文章(但是“阅读更多...”下面的文本怎么样?),然后使用 XML-RPC* 对文章发表评论。是这样吗,或者谁有更好的解决方案? (*metaWeblog.getRecentPosts 在 WP 上并不总是可用)
对于相关博客的实现我没有太多要说的,尽管我可以要求所有者安装一些插件。例如WP-RESTful。
请为我指明正确的方向,因为我花了几天时间寻找一个应该很简单的解决方案,但似乎并非如此。谢谢!
No matter where I look, I just can't find a way to fully connect my app to Wordpress. What I'd like to do is: show recent articles (published, of course) and older ones when you're not logged in and facilitate writing comments for users that are.
It just looks like I have to pull the blog articles from RSS (but what about the text below 'Read More...'?), and then use XML-RPC* to comment on the articles. Is that the way, or does anyone have a better solution? (*metaWeblog.getRecentPosts isn't always available on WP)
I don't have a lot to say about the implementation of the blog in question, though I could ask the owner to install some plugins. Such as WP-RESTful.
Please point me in the right direction to look, because I've spent days searching for a solution that should be simple but just doesn't seem to be that way. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WordPress 移动团队有一个用于他们使用的 XML-RPC 解析器的存储库。它的实施和使用相当简单。它由
XMLRPCDecode
和XMLRPCEncoder
组成。https://github.com/wordpress-mobile/wpxmlrpc
编辑
WordPress 中的
XML-RPC
旨在用于发布。获取帖子的功能非常有限,因为 WordPress 实现在wp.getPosts
方法中使用了wp_get_recent_posts()
。我通过采用class-wp-xmlrpc-server.php
中的wp_getPosts
方法并将wp_get_recent_posts
替换为get_posts< /代码>。因此我可以使用 Wp_Query 类中的所有参数。
然后使用
xmlrpc_method
过滤器覆盖内置方法。如果你愿意的话,我可以发布代码。编辑 II
没关系,我会发布代码...:)
The WordPress mobile team has a repository for the XML-RPC parser they use. It's fairly simple to implement and use. It consists of a
XMLRPCDecode
andXMLRPCEncoder
.https://github.com/wordpress-mobile/wpxmlrpc
EDIT
XML-RPC
in WordPress is intended for posting. The functionalities for getting posts are quite limited because the WordPress implementation useswp_get_recent_posts()
in thewp.getPosts
method. I made the function better by adopting thewp_getPosts
method inclass-wp-xmlrpc-server.php
and replacingwp_get_recent_posts
byget_posts
. So I can use all parameters like inWp_Query
class.The
xmlrpc_method
filter is then used to override the built in methods. I could post the code, if you want.EDIT II
Nevermind, I'll post the code... :)
我认为 xmlrpc 是可行的方法,例如 WP 自己的应用程序就是这样连接的。为什么不使用它来获取帖子,为什么使用 RSS 呢?
I think xmlrpc is the way to go, that's the way WP's own app connects for instance. Why don't you use it to get the posts as well, why use RSS for that?