The GitHub Project xm-rpc-el/xml-rpc-el README.org
Commentary:
This is an XML-RPC client implementation in elisp, capable of both synchronous and asynchronous method calls (using the url package's async retrieval functionality).
XML-RPC is remote procedure calls over HTTP using XML to describe the function call and return values.
xml-rpc.el represents XML-RPC datatypes as lisp values, automatically converting to and from the XML datastructures as needed, both for method parameters and return values, making using XML-RPC methods fairly transparent to the lisp code.
Installation:
If you use ELPA, and have configured the NonGNU ELPA or MELPA repository, then M-x package-install RET xml-rpc RET
interface. This is preferable as you will have access to updates automatically.
If you would like to use ELPA, but this is your first time to use it, or NonGNU ELPA/MELPA, then try evaluating the following code in emacs:
(progn (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (unless (package-installed-p 'xml-rpc) (with-temp-buffer (url-insert-file-contents "https://raw.githubusercontent.com/xml-rpc-el/xml-rpc-el/master/xml-rpc.el") (package-install-from-buffer))))
Otherwise, just make sure this file in your load-path (usually ~/.emacs.d
is included) and put
(require 'xml-rpc)
in your ~/.emacs
or ~/.emacs.d/init.el
file.
Requirements
xml-rpc.el uses the url package for http handling and xml.el
for XML parsing or, if you have Emacs 27+ with libxml
included, libxml
. The url package that is part of Emacs works fine.
Bug reports
Please use M-x xml-rpc-submit-bug-report
to report bugs directly to the maintainer, or use github's issue system.
Representing data types
XML-RPC datatypes are represented as follows
type | data |
int | 42 |
float/double | 42.0 |
string | "foo" |
base64 | (list :base64 |
(base64-encode-string "hello" t)) | |
'(:base64 "aGVsbG8=") | |
array | '(1 2 3 4) '(1 2 3 (4.1 4.2)) [ ] |
'(:array (("not" "a") ("struct" "!"))) | |
struct | '(("name" . "daniel") |
("height" . 6.1)) | |
dateTime | '(:datetime (1234 124)) |
Examples
Here follows some examples demonstrating the use of xml-rpc.el
Normal synchronous operation
(xml-rpc-method-call "http://localhost:80/RPC" 'foo-method foo bar zoo)
Asynchronous example (cb-foo will be called when the methods returns)
(defun cb-foo (foo) (print (format "%s" foo))) (xml-rpc-method-call-async 'cb-foo "http://localhost:80/RPC" 'foo-method foo bar zoo)
Some real world working examples for fun and play
These were last tested working on 2020-09-06.
Fetch the first state name from UserLand's server
(xml-rpc-method-call "http://betty.userland.com/rpc2" 'examples.getStateName '(1))
Results in:
Alabama
Get a list of supported methods from a blog
(mapconcat (lambda (s) (when s s)) (xml-rpc-method-call "https://hexmode.wordpress.com/xmlrpc.php" 'mt.supportedMethods) ", ")
Results in:
wp.getUsersBlogs, wp.newPost, wp.editPost, wp.deletePost, wp.getPost, wp.getPosts, wp.newTerm, wp.editTerm, wp.deleteTerm, wp.getTerm, wp.getTerms, wp.getTaxonomy, wp.getTaxonomies, wp.getUser, wp.getUsers, wp.getProfile, wp.editProfile, wp.getPage, wp.getPages, wp.newPage, wp.deletePage, wp.editPage, wp.getPageList, wp.getAuthors, wp.getCategories, wp.getTags, wp.newCategory, wp.deleteCategory, wp.suggestCategories, wp.uploadFile, wp.deleteFile, wp.getCommentCount, wp.getPostStatusList, wp.getPageStatusList, wp.getPageTemplates, wp.getOptions, wp.setOptions, wp.getComment, wp.getComments, wp.deleteComment, wp.editComment, wp.newComment, wp.getCommentStatusList, wp.getMediaItem, wp.getMediaLibrary, wp.getPostFormats, wp.getPostType, wp.getPostTypes, wp.getRevisions, wp.restoreRevision, blogger.getUsersBlogs, blogger.getUserInfo, blogger.getPost, blogger.getRecentPosts, blogger.newPost, blogger.editPost, blogger.deletePost, metaWeblog.newPost, metaWeblog.editPost, metaWeblog.getPost, metaWeblog.getRecentPosts, metaWeblog.getCategories, metaWeblog.newMediaObject, metaWeblog.deletePost, metaWeblog.getUsersBlogs, mt.getCategoryList, mt.getRecentPostTitles, mt.getPostCategories, mt.setPostCategories, mt.supportedMethods, mt.supportedTextFilters, mt.getTrackbackPings, mt.publishPost, pingback.ping, pingback.extensions.getPingbacks, demo.sayHello, demo.addTwoNumbers, wpStats.get_key, wpStats.check_key, wpStats.get_blog_id, wpStats.get_site_id, wpStats.update_bloginfo, wpStats.update_postinfo, wpStats.ping_blog, wpStats.flush_posts, wpcom.get_user_blogids, wpcom.getFeatures, wpcom.addApplicationPassword, wpcom.blackberryUploadFile, wpcom.blackberryGetUploadingFileKeys, wpcom.getUsersSubs, wpcom.set_mobile_push_notification_settings, wpcom.get_mobile_push_notification_settings, wpcom.mobile_push_register_token, wpcom.mobile_push_unregister_token, wpcom.mobile_push_set_blogs_list, wpcom.mobile_push_win_phone_get_last_notification
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理