Wordpress API Primer (V - MetaWeblog API)

April 3rd, 2007 | Architecture | Internet

Out of the three supported API, MetaWeblog API documentation is the only one that has not moved - it is located here.

The main difference between MetaWeblog & Blogger API is that MetaWeblog extends the Blogger API by passing a struct for the post rather than just a string for the content.

The explanation on the spec page has one confusing point: it mentioned that the struct contains the elements defined in RSS 2.0 - this can be read as that struct has the same XML markup as RSS 2.0. This is NOT the case. The struct still has the same XML markup in XMLRPC, but it can have member with the names of link, title, description, etc.

The main methods are:

From the archive: Tips on Hacking CSS

January 27th, 2007 | Blogging | Design

I am busy hacking away on a new theme (based on Chris Pearson’s Cutline), and that is why I have not added much content right now.

Below are some of the tips I found out when trying to hack CSS:

  • Use multiple lines with each style: when there are multiple declarations on a single line, it is hard to tell how to modify it, especially when viewing through a SSH terminal. While it might look nice on a 24 inch monitor (I would assume most designers would have the best monitors they can buy, it is still easier to scroll down than scroll left or right.
  • Use CSS Validator to know whether your change is valid: W3C’s CSS Validator is very handy in telling you where things are wrong. I quickly found a few errors that would have been hard to spot in a 700 line file with the service, and it also comes with a badge once your file passes the validation ;)
  • Use @import liberally: @import helps you to break up a monotone CSS file and bring some modularity and organization to keep it from growing into a monstrous beast that would be difficult to maintain. I am glad that CSS has such a facility, otherwise I would have to build one ;)
  • Understand CSS inheritance rules: Coming from programming background, I think more in object type inheritance than container inheritance, and run into troubles hacking CSS until I realized the differences. Understand the concept will save you time ;)
  • Keep references handy: There are just too many CSS properties to remember for a casual web designer. Luckily the web has a ton of such information ;) I found W3CSchools works well for the basic references and can serve 80% of the needs. And sometimes digging into the actual spec source is inevitable, but those situations always provide invaluable learning.

Wordpress API Primer (IV - Blogger API)

March 28th, 2007 | Architecture | Internet

Blogger API is one of the earliest Blogging API’s, and it has been around for a long time. Currently Blogger is moving to ATOM, so if you just click on the Blogger API link, it’s going to take you to a blog. Google broke its own links, basically.

So where is the actual Blogger API documentations nowadays? I forgot how I found it, but it’s here:

And the first thing you will see when going to the link is the highlighted warning that says:

Note: This API will be deprecated soon; please use the Atom API instead. - Eric, 4/2006

The nice thing is that we are learning about WP’s API, so unless WP decides to follow suit, we don’t have to worry about the warning ;)

Limitations

The reason for its obsolescence is because the API is limited - it can only post content; not title, categories, and other things that you have come to expect from a blogging platform. I don’t know why the API is this limited, but perhaps once upon a time that was all people need. This is no longer true today (and hence WP’s support for MetaWeblog & MovableType API).

Regardless of its limitations, because of its early status and influence on upcoming API’s, it is still important to know. And hopefully Blogger does not decide to take down these pages soon ;) (they probably break the link because they want to obsolete the API, but that makes it difficult for others trying to figure out WP)

API

Below are the methods supported in Blogger API:

  • blogger.newPost: Makes a new post to a designated blog. Optionally, will publish the blog after making the post.
  • blogger.editPost: Edits a given post. Optionally, will publish the blog after making the edit.
  • blogger.getUsersBlogs: Returns information on all the blogs a given user is a member of.
  • blogger.getUserInfo: Authenticates a user and returns basic user info (name, email, userid, etc.).
  • blogger.getTemplate: Returns the main or archive index template of a given blog.
  • blogger.setTemplate: Edits the main or archive index template of a given blog.

From WP perspective, the necessary methods are Blogger.getUsersBlogs & Blogger.getUserInfo (possibly getTemplate & setTemplate as well, but I’ve not had uses for it). For the posting capabilities we need to look at MetaWeblog & MovableType, which we will discuss in the next article.

Wordpress API Primer (III - xmlrpc.php)

March 21st, 2007 | Architecture | Programming

Just which methods do Wordpress supports exactly? The best way to know is to look at the source (because source code is the design document). You will find the following if you look at the xmlrpc.php located in the root directory of your WP installation (the version I have is 2.0.5).


$this->methods = 
array(
      // 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',
      
      // MetaWeblog API (with MT extensions to structs)
      'metaWeblog.newPost' => 'this:mw_newPost',
      'metaWeblog.editPost' => 'this:mw_editPost',
      'metaWeblog.getPost' => 'this:mw_getPost',
      'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',
      'metaWeblog.getCategories' => 'this:mw_getCategories',
      'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',
      
      // MetaWeblog API aliases for Blogger API
      // see http://www.xmlrpc.com/stories/storyReader$2460
      'metaWeblog.deletePost' => 'this:blogger_deletePost',
      'metaWeblog.getTemplate' => 'this:blogger_getTemplate',
      'metaWeblog.setTemplate' => 'this:blogger_setTemplate',
      'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',
      
      // MovableType API
      'mt.getCategoryList' => 'this:mt_getCategoryList',
      'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',
      'mt.getPostCategories' => 'this:mt_getPostCategories',
      'mt.setPostCategories' => 'this:mt_setPostCategories',
      'mt.supportedMethods' => 'this:mt_supportedMethods',
      'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
      'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
      'mt.publishPost' => 'this:mt_publishPost',
      
      // PingBack
      'pingback.ping' => 'this:pingback_ping',
      'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',

      'demo.sayHello' => 'this:sayHello',
      'demo.addTwoNumbers' => 'this:addTwoNumbers'
      );


And below is the relevant extracted list from the source code:

  • blogger.getUsersBlogs
  • blogger.getUserInfo
  • blogger.getPost
  • blogger.getRecentPosts
  • blogger.getTemplate
  • blogger.setTemplate
  • blogger.newPost
  • blogger.editPost
  • blogger.deletePost
  • metaWeblog.newPost
  • metaWeblog.editPost
  • metaWeblog.getPost
  • metaWeblog.getRecentPosts
  • metaWeblog.getCategories
  • metaWeblog.newMediaObject
  • metaWeblog.deletePost
  • metaWeblog.getTemplate
  • metaWeblog.setTemplate
  • metaWeblog.getUsersBlogs
  • mt.getCategoryList
  • mt.getRecentPostTitles
  • mt.getPostCategories
  • mt.setPostCategories
  • mt.supportedMethods
  • mt.supportedTextFilters
  • mt.getTrackbackPings
  • mt.publishPost

The ones with blogger prefix are Blogger API methods. The ones with metaWeblog prefix are MetaWeblog methods, and the ones with mt prefix are MovableType methods.

We will cover the different API’s next.

Wordpress API Primer (II - XMLRPC)

March 18th, 2007 | Miscellaneous

The foundation of Wordpress API is built on XMLRPC, and hence if you want to know how the API works then you need to know XMLRPC.

XMLRPC Specification

The authoritative source about XMLRPC is its spec, which includes the following information:

  1. Sample request & response
  2. Method name
  3. XML representation of scalar data (boolean, integer, double, date, string, and base64)
  4. XML representation of complex data (array and struct)
  5. Failure response

You might find the spec itself is a bit sparse (which is a prevalent feature in the whole xmlrpc.com), and might want to have some tutorials and samples to go along with the information. Furthermore, who wants to manually construct XML these days?? We want a library to do the work!

PHP Implementations of XMLRPC

It turns out that many people have answered the call - I found that at least 5 major branches of XMLRPC libraries in PHP (there are probably more, but I can’t boil the ocean ;P):

How should one go about choosing the right package to use? Below is my quick checklist for decision points:

  • Is the library stable?
  • Will the library be supported?
  • Will the library be available?
  • Will the library require additional effort to get setup (e.g. require compilation process)?

And how the libraries stack up:

Library Stability Support Available Effort Conclusion
PHP Extension Experimental, although based on a stable codebase Not actively supported by PHP due to experimental status It is included with all PHP distribution, but not compiled or enabled by default It can be cumbersome to setup Probably not the best library to use and depend on
XMLRPC-EPI Appears to be stable codebase, since 1998 Last update since 2002, so not sure whether it’s actively supported Not included by default Requires C compiler, which can be cumbersome Unless speed is absolutely critical, it might not make sense to use this library
PEAR::XML_RPC Appears to be stable codebase Appears to be actively supported, since it is in PEAR Requires PEAR and not included by default Requires users to setup PEAR and depends on PEAR While PEAR is awesome, it just introduces additional dependency
XML-RPC Appears to be stable codebase Appears to be actively supported, latest release in 2007 Can easily be included in your code No additional effort to setup A good choice for distribution
Incutio XML-RPC Appears to be a stable codebase The activity on the package appears to be sparse sync 2005 Can easily be included in your code No additional effort to setup IMHO - the easiest package that I’ve found

Conclusion

While the pure library XML-RPC package such as Useful Inc’s or Incutio’s do not necessarily offer speed, IMHO they are easier to include for distribution, better documentation, and possibly active support.

When comparing the two package, what I found is that:

  • Useful Inc’s has more active development and better documentations
  • But Incutio’s is easier to use, and is used in WP

What really sold me with Incutio’s package is that by default it assumes that you shouldn’t have to even think in XML at all - it helps you handle as much of conversion from XML to PHP objects as possible, where Useful Inc’s version still requires you to explicitly control the conversion (it does have helper functions that will simplify the process). Incutio’s abstraction will help speed up the development of a WP XMLRPC client.

We will talk about the various API for WP next.

Wordpress API Primer (I - Overview)

March 14th, 2007 | Geekcraft | Architecture | Internet

Overview

This series of articles is about Wordpress API - how to interface with Wordpress to create posts and manage posts without having to dig into its internal data structures. I have chance to take a look at WP’s internal, and it is certainly not for the faint of heart (or the lack of time), and external API are definitely more stable in the name of upgrades and changes.

It turns out that Wordpress DOES have an external API:

WordPress uses an XML-RPC interface. We currently support the Blogger API, metaWeblog API, and the Movable Type API .

You can always develop your own. Many scripts in Perl, Python, PHP, Applescript and Java have already been written and are ripe for the picking (and tweaking).

Keep reading →

Web Clippings (Geekcraft) - 3/2/2007

March 2nd, 2007 | Geekcraft

Below are the web clippings of the day. Enjoy.

Monthly Report February 2007

February 28th, 2007 | Miscellaneous | Meta

The following are the stats for February 2007:

  • Posts: 16 posts for 20 weekdays - 4 posts/week
  • Visits: 905
  • Page Views: 1,802
  • Average: 1.99 pages/visit

This is of course a big decrease from January - good thing this drop is by design ;) So what happened?

  1. I spend majority of time developing instead of writing.

  2. The traffic from Reddit is dying down without being renewed.

As noted in the How to Generate Compelling Content series, going forward I am leveraging my technical skills to bring content to this site. You probably have noticed the Web Clippings for different categories (Bizscape, Leaderware, etc), and these are generated by my script that can pull from del.icio.us by different tags. I am also working on a couple other ways of pulling contents, but as they are more complex they are still in development progress.

Right now I am going through the process of refining the script and add documentations so I can release it for wide use. If you are interested in having similar functionality, stay tuned ;)

Web Clippings (Leaderware) - 2/28/2007

February 28th, 2007 | Leaderware

Below are the web clippings of the day. Enjoy.

  • Stevey’s Home Page - Being the Averagest

    Can you tell if someone is a great developer? Or is he/she just one who is very used to do things a particular way who never thought to improve beyond what he/she already knows how to do?

  • Why you cannot learn much from past success - lifehack.org

    People really learn more from mistakes and failures than from successes.

  • Creating Passionate Users: Are our tools making us dumber?

    The title says it all - are we becoming less capable because our tool are doing the work for us so we don’t have to think? When was the last time you did calculations by hand and do you still remember? I sure don’t ;)

  • Rands In Repose: 1.0

    Rands has an interesting model to look at version 1.0 companies and why it almost always fails. IMO the more technical the founders are, the less gap between pitch and product and the more likely it can succeed.

  • So you want to be a consultant…?

    What it takes to be a consultant from someone who has been doing it since 1985. IMO, this is what it takes to be a professional, period, regardless of the status (i.e. employee, contractor, consultants).

  • Creating Passionate Users: Don’t make the Demo look Done

    How to set the right expectations with stakeholders/users/etc on the current progress of the project through demos. If one uses polished demo early on, things will look done and the feedback will be minimal.

Web Clippings (Bizscape) - 2/26/2007

February 26th, 2007 | Bizscape

Below are the web clippings of the day. Enjoy.

Web Clippings (Tippoint) - 2/25/2007

February 25th, 2007 | Tippoint

Below are the web clippings of the day. Enjoy.

  • Secret Confessions of a Link-A-Holic

    Coming from Darren Rowes on why one should not become obsessed about link buildings. It is all about putting the content first - blog well builds the foundation for which success can follow - linking is secondary.

  • Google Related Links

    Google Related Links use the power of Google to automatically bring fresh, dynamic and interesting content links to any website.

  • Who Do You Think You’re Talking To? | Copyblogger

    How can you ensure that your blog has a market? Treating blogging like running a business is key. Some research beforehand will save lots of grief later on.

  • Technorati tags: an introduction - A Consuming Experience

    A tutorial on what is technorati tags and how to use them in blogs. The post is not technically focused and instead talks more from an user’s perspective.