Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Intergrating with WordPress via XML-RPC
Search
Max Cutler
June 09, 2012
Programming
3
4.6k
Intergrating with WordPress via XML-RPC
Talk at WordCamp NYC, June 9, 2012
Max Cutler
June 09, 2012
Tweet
Share
More Decks by Max Cutler
See All by Max Cutler
Browser Performance - Fundamentals, Tools & Techniques
maxcutler
1
2k
XML-RPC and RESTful APIs: Breaking Down the WordPress Silo
maxcutler
0
120
Hack with Me: Unit and Behavioral Tests
maxcutler
2
410
Other Decks in Programming
See All in Programming
Comparing decimals in Swift Testing
417_72ki
0
130
[DevinMeetupTokyo2025] コード書かせないDevinの使い方
takumiyoshikawa
2
230
NEWT Backend Evolution
xpromx
1
170
AI時代の『改訂新版 良いコード/悪いコードで学ぶ設計入門』 / ai-good-code-bad-code
minodriven
24
10k
CIを整備してメンテナンスを生成AIに任せる
hazumirr
0
370
Vibe Codingの幻想を超えて-生成AIを現場で使えるようにするまでの泥臭い話.ai
fumiyakume
20
9.7k
バイブコーディング超えてバイブデプロイ〜CloudflareMCPで実現する、未来のアプリケーションデリバリー〜
azukiazusa1
2
740
Reactの歴史を振り返る
tutinoko
1
150
React は次の10年を生き残れるか:3つのトレンドから考える
oukayuka
41
16k
新しいモバイルアプリ勉強会(仮)について
uetyo
1
230
The Niche of CDK Grant オブジェクトって何者?/the-niche-of-cdk-what-isgrant-object
hassaku63
1
720
顧客の画像データをテラバイト単位で配信する 画像サーバを WebP にした際に起こった課題と その対応策 ~継続的な取り組みを添えて~
takutakahashi
4
1.4k
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
184
22k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Side Projects
sachag
455
43k
Why Our Code Smells
bkeepers
PRO
337
57k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.9k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
770
Agile that works and the tools we love
rasmusluckow
329
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
283
13k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
400
Transcript
Integrating with WordPress via XML-RPC Max Cutler WordCamp NYC 2012
Who am I? • http://maxcutler.com • @maxcutler • Student •
WordPress for Windows Phone • Core Contributor for XML-RPC in 3.4
Motivation What is XML-RPC? WordPress & XML-RPC Examples Tips for
plugin and theme authors What’s next?
Motivation What is XML-RPC? WordPress & XML-RPC Examples Tips for
plugin and theme authors What’s next?
Cross-system interoperability
Escape the data silo
Motivation What is XML-RPC? WordPress & XML-RPC Examples Tips for
plugin and theme authors What’s next?
“Simple cross-platform distributed computing, based on the standards of the
Internet.” xmlrpc.com
RPC using XML serialization
Sample Exchange - Request POST /xmlrpc.php HTTP/1.0 User-Agent: Max’s API
Client Host: maxcutler.com Content-Type: text/xml <?xml version="1.0"?> <methodCall> <methodName>wp.getUsersBlogs</methodName> <params> <param><value>maxcutler</value></param> <param><value>L1nk3d1nr0ck$</value></param> </params> </methodCall>
Sample Exchange - Response HTTP/1.0 200 OK Content-Type: text/xml <?xml
version="1.0"?> <methodResponse> <params><param><value><array><data><value><struct> <member><name>isAdmin</name> <value><boolean>1</boolean></value></member> <member><name>url</name> <value>http://www.maxcutler.com/</value></member> <member><name>blogid</name> <value>1</value></member> <member><name>blogName</name> <value>Max Cutler</value></member> <member><name>xmlrpc</name> <value>http://www.maxcutler.com/xmlrpc.php</value></member> </struct></value></data></array></value></param></params> </methodResponse>
Libraries for every language • PHP/WordPress – IXR • Python
– xmlrpclib • Ruby – XMLRPC::Client • Perl – RPC::XML • C# - XML-RPC.NET • Java – ws-xmlrpc • JavaScript – Mimic, node-xmlrpc • And many more…
Motivation What is XML-RPC? WordPress & XML-RPC Examples Tips for
plugin and theme authors What’s next?
xmlrpc.php • WordPress.com • Off-by-default on WordPress.org • wp-includes/class- wp-xmlrpc-server.php
History • r1348 (May 2004) – xmlrpc.php born • 1.5
– Blogger, MovableType, metaWeblog, and pingback APIs • 2.2 - Pages • 2.5 – Categories, Custom Fields • 2.6 – Options/Settings • 2.7 – Comments • 3.1 – Media Library (read or upload)
History – 3.3 blogger.getUsersBlogs blogger.getUserInfo blogger.getPost blogger.getRecentPosts blogger.newPost blogger.editPost blogger.deletePost
metaWeblog.newPost metaWeblog.editPost metaWeblog.deletePost metaWeblog.getPost metaWeblog.getRecentPosts metaWeblog.getCategories metaWeblog.newMediaObject metaWeblog.getUsersBlogs pingback.ping pingback.extensions mt.getCategoryList mt.getRecentPostTitles mt.getPostCategories mt.setPostCategories mt.publishPost mt.getTrackbackPings wp.getUsersBlogs wp.getAuthors wp.getPage wp.getPages wp.newPage wp.editPage wp.deletePage wp.getPageList wp.getPageTemplates wp.getPageStatusList wp.getCategories wp.getTags wp.newCategory wp.deleteCategory wp.suggestCategories wp.getCommentCount wp.getComment wp.getComments wp.newComment wp.getCommentStatusList wp.getOptions wp.setOptions wp.uploadFile wp.getMediaItem wp.getMediaLibrary wp.getPostFormats wp.getPostStatusList demo.sayHello demo.addTwoNumbers system.listMethods
Can we clean this up? • Limited or no support
for 3.x core features • Widespread inconsistency of parameters and return values • Abuse of legacy method fields postid title description dateCreated date_created_gmt permaLink link title description mt_excerpt mt_text_more wp_more_text mt_allow_comments mt_allow_pings mt_keywords categories wp_slug wp_password userid wp_author_id wp_author_display_name post_status custom_fields wp_post_format sticky enclosure
Today – 3.4 • Unified post types • Unified taxonomies
• More useful media • Actions & filters • Bug-fixes • Unit tests (!!!) http://codex.wordpress.org/XML-RPC_WordPress_API wp.getPost wp.getPosts wp.newPost wp.editPost wp.deletePost wp.getPostType wp.getPostTypes wp.getPostFormats wp.getPostStatusList wp.getTaxonomy wp.getTaxonomies wp.getTerm wp.getTerms wp.newTerm wp.editTerm wp.deleteTerm wp.getMediaItem wp.getMediaLibrary wp.uploadFile wp.getCommentCount wp.getComment wp.getComments wp.newComment wp.editComment wp.deleteComment wp.getCommentStatusList wp.getOptions wp.setOptions wp.getUsersBlogs wp.getAuthors
Method analogies WordPress Core API XML-RPC Method get_posts wp.getPost, wp.getPosts
wp_insert_post wp.newPost, wp.editPost get_taxonomy wp.getTaxonomy, wp.getTaxonomies get_terms wp.getTerm, wp.getTerms wp_insert_term wp.newTerm wp_update_term wp.editTerm get_post_types wp.getPostType, wp.getPostTypes get_comments wp.getComment, wp.getComments
Motivation What is XML-RPC? WordPress & XML-RPC Examples Tips for
plugin and theme authors What’s next?
Clients • Language • Standard Library • 3rd-party libraries &
wrappers – PHP: IXR_Client (ships with WordPress) – Python: python-wordpress-xmlrpc – Node.js: node-wordpress – C#/.NET: JoeBlogs
Post Querying • wp.getPosts – Filter • post_type, number, offset,
order, orderby – Fields • Meta-fields: post, taxonomies, custom_fields • Individual fields – post_id, post_title, post_date, post_date_gmt, post_modified, post_modified_gmt, post_status, post_type, post_name, post_author, post_password, post_excerpt, post_content, link, comment_status, ping_status, sticky, post_format, terms, custom_fields, enclosure
Post Querying wp.getPosts( 0, username, password, array( ‘post_type’ => ‘product’,
‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ), array( ‘post_title’, ‘date_modified_gmt’, ‘link’ ) )
Post Creation wp.newPost( 0, username, password, array( ‘post_title’ => ‘Hello
world’, ‘post_content’ => …, ‘terms_names’ => array( ‘post_tag’ => array( ‘day1’ ), ‘category’ => array( ‘introductions’ ) ) ) )
Post Creation (2) wp.newPost( 0, username, password, array( ‘post_type’ =>
‘product’, ‘post_title’ => ‘ACME’, ‘post_content’ => …, ‘custom_fields’ => array( array( ‘key’ => ‘price’, ‘value’ => 15 ) ) ) )
Real world examples
Mobile Apps http://wordpress.org/extend/mobile/
Offline Writing Applications Windows Live Writer, MarsEdit, ecto, etc.
Jetpack
Chicago Tribune News Apps Varnish Caching Unit Tests http://blog.apps.chicagotribune.com/2011/06/28/dont-break-the-homepage-using-unit-tests- to-validate-your-wordpress-varnish-caching-strategy/
Generate WordPress site using build tools https://github.com/scottgonzalez/grunt-wordpress github.com/jquery/api.jquery.com (XML files
in git repo) grunt-wordpress (XML-RPC bridge) api.jquery.com (WordPress site)
External Search Django + Haystack + Solr
Camayak Editorial content production with multiple-site remote publishing Camayak WordPress
InDesign NITF Drupal
Motivation What is XML-RPC? WordPress & XML-RPC Examples Tips for
plugin and theme authors What’s next?
http://codex.wordpress.org/ XML-RPC_Support http://codex.wordpress.org/ XML-RPC_Extending
Add/remove methods xmlrpc_methods filter function mynamespace_subtractTwoNumbers( $args ) { $number1
= (int) $args[0]; $number2 = (int) $args[1]; return $number1 - $number2; } function mynamespace_new_xmlrpc_methods( $methods ) { $methods['mynamespace.subtractTwoNumbers'] = 'mynamespace_subtractTwoNumbers'; return $methods; } add_filter( 'xmlrpc_methods', mynamespace_new_xmlrpc_methods');
Adjust return values • xmlrpc_default_*_fields – post, posttype, taxonomy •
xmlrpc_prepare_* – post, post_type, taxonomy, term, media_item, comment, page • xmlrpc_blog_options • wp_handle_upload • Use the source, Luke!
PSA: Omit Trailing “?>”
Motivation What is XML-RPC? WordPress & XML-RPC Examples Tips for
plugin and theme authors What’s next?
Using 3.3 or earlier? Shim for 3.4 additions in my
plugin: http://wordpress.org/extend/plugins /xml-rpc-modernization/
WordPress 3.5? User management Even more media enhancements Improved custom
fields JSON Serialization
REST API v1 on http://developer.wordpress.com v2 in core? TBD
http://codex.wordpress.org/ XML-RPC_Support
Thanks! Q&A