WordPress APIs

       Joseph Scott
  http://josephscott.org/
APIs - The Big Two

     XML-RPC
        &
     AtomPub
XML-RPC Basics
• XML over HTTP POST
• Basic data types (int, bool, string, double,
  dateTime.iso8601, base64) combined wi...
XML-RPC Request
<?xml version=quot;1.0quot;?>
<methodCall>
	 <methodName>metaWeblog.getPost</methodName>
	 <params>
	   	 ...
XML-RPC Response
<?xml version=quot;1.0quot;?>
<methodResponse>
  <params>
    <param>
      <value>
        <struct>
    ...
AtomPub Basics
• XML over HTTP (GET, POST, PUT, DELETE)
• Shared base with Atom feeds
• Collections (Posts, Comments, Medi...
AtomPub Request

curl -u “admin:happiness” 
http://localhost/~joseph/wp/trunk/wp-app.php/post/1
AtomPub Response
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<entry xmlns=quot;http://www.w3.org/2005/Atomquot;...
Discovery
• Really Simple Discovery (RSD)
• http://cyber.law.harvard.edu/blogs/gems/tech/
  rsd.html
<link rel=quot;EditUR...
RSD
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<rsd version=quot;1.0quot; xmlns=quot;http://archipelago.phrase...
4,619

3,079,080
2008 Totals
  4,619
   AtomPub



3,079,080
  XML-RPC
2009 Year To Date
     3,312
      AtomPub



    703,673
      XML-RPC
XML-RPC Blog APIs
 MetaWeblog
                       WordPress
(metaWeblog.*)
                        (wp.*)

          Bl...
Extending MetaWeblog
• Many new fields to getPost/newPost/editPost
 • wp_slug, wp_password, wp_author_id,
    wp_author_dis...
WordPress Methods
• Comment Management, new in 2.7
  (wp.getComment, wp.newComment,
  wp.editComment, wp.deleteComment)
• ...
Applications
Windows Live Writer
                        MarsEdit
More Applications
  http://codex.wordpress.org/Weblog_Client

• Scribefire (Firefox Plugin)
• Windows- MS Word 2007, Blogde...
iPhone App
 • http://iphone.wordpress.org/
 • Free & Open Source (GPL)
 • ~ 165,000 downloads
 • Uses XML-RPC to manage
  ...
iPhone App - 1.2
http://iphone.wordpress.org/2008/11/11/help-test-
         wordpress-for-iphone-version-12/

 • Comment M...
iPhone App

      231,079

Posts in the last 6 months
Developer Tools - Mac
        HTTPScoop
        http://www.tuffcode.com/


           XML-RPC Client
           http://dit...
Developer Tools - Windows
Fiddler
http://www.fiddlertool.com/fiddler/
XML-RPC for WP Devs
  • Add your own XML-RPC methods
add_filter( 'xmlrpc_methods', 'joseph_attach_xmlrpc_methods' );
functi...
XML-RPC for WP Devs
     • Add your own XML-RPC methods
function joseph_xmlrpc_hello( $args ) {
   if ( empty( $args[0] ) ...
XML-RPC for WP Devs
   • XML-RPC Client
$rpc = new IXR_Client( 'http://example.com/xmlrpc.php' );

$status = $rpc->query( ...
bbPress XML-RPC
• Part of version 1.0 (when it comes out)
• Pingback support
• bbPress Live - WordPress Plugin
• BuddyPres...
Going Forward
• More data/features exposed via XML-RPC &
  AtomPub
 • Everything wp-admin can do?
• Likely a WordPress nam...
Username
Password
OAuth

Username
Password
Applications On Top
  of WordPress
InterPress
XML-RPC Developers
http://lists.automattic.com/mailman/listinfo/wp-xmlrpc
Thank You
Find Me

• http://josephscott.org/
• joseph@josephscott.org
• http://twitter.com/josephscott/
• #wordpress-dev
Upcoming SlideShare
Loading in …5
×

WordPress APIs

5,731 views
5,677 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,731
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
50
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

WordPress APIs

  1. 1. WordPress APIs Joseph Scott http://josephscott.org/
  2. 2. APIs - The Big Two XML-RPC & AtomPub
  3. 3. XML-RPC Basics • XML over HTTP POST • Basic data types (int, bool, string, double, dateTime.iso8601, base64) combined with structs and arrays • Supports pipelining with system.multicall • Authentication generally in request body • Spec - xmlrpc.com/spec
  4. 4. XML-RPC Request <?xml version=quot;1.0quot;?> <methodCall> <methodName>metaWeblog.getPost</methodName> <params> <param> <value><int>1</int></value> </param> <param> <value><string>admin</string></value> </param> <param> <value><string>happiness</string></value> </param> </params> </methodCall>
  5. 5. XML-RPC Response <?xml version=quot;1.0quot;?> <methodResponse> <params> <param> <value> <struct> <member><name>postid</name><value><string>1</string></value></member> to <member><name>description</name><value><string>Welcome WordPress. This is your first post. Edit or delete it, then start blogging!</string></value></member> <member><name>title</name><value><string>Hello world!</string><value></ member> ... </struct> </value> </param> </params> </methodResponse>
  6. 6. AtomPub Basics • XML over HTTP (GET, POST, PUT, DELETE) • Shared base with Atom feeds • Collections (Posts, Comments, Media), Entries (Individual posts and comments) • Great intro from Joe Gregorio - http:// bitworking.org/news/343/intro-to-atompub- on-youtube • http://tools.ietf.org/html/rfc5023
  7. 7. AtomPub Request curl -u “admin:happiness” http://localhost/~joseph/wp/trunk/wp-app.php/post/1
  8. 8. AtomPub Response <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <entry xmlns=quot;http://www.w3.org/2005/Atomquot; xmlns:app=quot;http://www.w3.org/2007/appquot; xml:lang=quot;enquot;> <id>http://localhost/~joseph/wp/trunk/?p=1</id> <title type=quot;textquot;>Hello world!</title> <updated>2008-08-08T01:01:03Z</updated> <published>2008-08-08T01:01:03Z</published> <app:edited>2008-08-08T01:01:03Z</app:edited> <app:control> <app:draft>no</app:draft> </app:control> <author><name>admin</name></author> <link href=quot;http://localhost/~joseph/wp/trunk/?p=1quot; /> <content type=quot;textquot;>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</content> <link rel=quot;editquot; href=quot;http://localhost/~joseph/wp/trunk/wp-app.php/post/1quot; /> <category scheme=quot;http://localhost/~joseph/wp/trunkquot; term=quot;Uncategorizedquot; /> <summary type=quot;textquot;>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</summary> </entry>
  9. 9. Discovery • Really Simple Discovery (RSD) • http://cyber.law.harvard.edu/blogs/gems/tech/ rsd.html <link rel=quot;EditURIquot; type=quot;application/rsd+xmlquot; title=quot;RSDquot; href=quot;http://localhost/wp/xmlrpc.php?rsdquot; />
  10. 10. RSD <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <rsd version=quot;1.0quot; xmlns=quot;http://archipelago.phrasewise.com/rsdquot;> <service> <engineName>WordPress</engineName> <engineLink>http://wordpress.org/</engineLink> <homePageLink>http://localhost/wp</homePageLink> <apis> <api name=quot;WordPressquot; blogID=quot;1quot; preferred=quot;truequot; apiLink=quot;http://localhost/ wpxmlrpc.phpquot; /> <api name=quot;Movable Typequot; blogID=quot;1quot; preferred=quot;falsequot; apiLink=quot;http://localhost/wp/ xmlrpc.phpquot; /> <api name=quot;MetaWeblogquot; blogID=quot;1quot; preferred=quot;falsequot; apiLink=quot;http://localhost/wp/ xmlrpc.phpquot; /> <api name=quot;Bloggerquot; blogID=quot;1quot; preferred=quot;falsequot; apiLink=quot;http://localhost/wp/ xmlrpc.phpquot; /> <api name=quot;Atomquot; blogID=quot;quot; preferred=quot;falsequot; apiLink=quot;http://localhost/~joseph/wp/wp- app.php/servicequot; /> </apis> </service> </rsd>
  11. 11. 4,619 3,079,080
  12. 12. 2008 Totals 4,619 AtomPub 3,079,080 XML-RPC
  13. 13. 2009 Year To Date 3,312 AtomPub 703,673 XML-RPC
  14. 14. XML-RPC Blog APIs MetaWeblog WordPress (metaWeblog.*) (wp.*) Blogger Movable Type (blogger.*) (mt.*)
  15. 15. Extending MetaWeblog • Many new fields to getPost/newPost/editPost • wp_slug, wp_password, wp_author_id, wp_author_display_name, date_created_gmt, post_status, custom_fields, mt_keywords (tags) • dateCreated vs. date_created_gmt
  16. 16. WordPress Methods • Comment Management, new in 2.7 (wp.getComment, wp.newComment, wp.editComment, wp.deleteComment) • Page management (wp.getPage, wp.editPage, wp.newPage, etc.) • Category Management (wp.newCategory, wp.deleteCategory, etc.) • Tag Management (wp.getTags - more to come)
  17. 17. Applications Windows Live Writer MarsEdit
  18. 18. More Applications http://codex.wordpress.org/Weblog_Client • Scribefire (Firefox Plugin) • Windows- MS Word 2007, Blogdesk, Blogjet, Raven, Flock, Qumana • Mac - Ecto, Blogo, MacJournal, TextMate • Linux - QTM, Gnome Blog, Drivel, BloGTK
  19. 19. iPhone App • http://iphone.wordpress.org/ • Free & Open Source (GPL) • ~ 165,000 downloads • Uses XML-RPC to manage your blog
  20. 20. iPhone App - 1.2 http://iphone.wordpress.org/2008/11/11/help-test- wordpress-for-iphone-version-12/ • Comment Moderation • Landscape mode • Link creation help • Create/edit Pages
  21. 21. iPhone App 231,079 Posts in the last 6 months
  22. 22. Developer Tools - Mac HTTPScoop http://www.tuffcode.com/ XML-RPC Client http://ditchnet.org/xmlrpc/
  23. 23. Developer Tools - Windows Fiddler http://www.fiddlertool.com/fiddler/
  24. 24. XML-RPC for WP Devs • Add your own XML-RPC methods add_filter( 'xmlrpc_methods', 'joseph_attach_xmlrpc_methods' ); function joseph_attach_xmlrpc_methods( $methods ) { $methods['joseph.hello'] = 'joseph_xmlrpc_hello'; return $methods; }
  25. 25. XML-RPC for WP Devs • Add your own XML-RPC methods function joseph_xmlrpc_hello( $args ) { if ( empty( $args[0] ) ) return new IXR_Error( 2000, __( 'No name was provided.' ) ); $salutation = quot;Hello {$args[0]}, nice to see you!quot;; return $salutation; }
  26. 26. XML-RPC for WP Devs • XML-RPC Client $rpc = new IXR_Client( 'http://example.com/xmlrpc.php' ); $status = $rpc->query( ‘demo.addTwoNumbers’, 4, 5 ); if ( !$status ) { print ‘Error ( ‘ . $rpc->getErrorCode( ) . ‘ ): ‘; print $rpc->getErrorMessage( ) . “n”; exit; } $result = $rpc->getResponse( );
  27. 27. bbPress XML-RPC • Part of version 1.0 (when it comes out) • Pingback support • bbPress Live - WordPress Plugin • BuddyPress forums
  28. 28. Going Forward • More data/features exposed via XML-RPC & AtomPub • Everything wp-admin can do? • Likely a WordPress namespace for new AtomPub features
  29. 29. Username Password
  30. 30. OAuth Username Password
  31. 31. Applications On Top of WordPress
  32. 32. InterPress
  33. 33. XML-RPC Developers http://lists.automattic.com/mailman/listinfo/wp-xmlrpc
  34. 34. Thank You
  35. 35. Find Me • http://josephscott.org/ • joseph@josephscott.org • http://twitter.com/josephscott/ • #wordpress-dev

×