[wp-hackers] Help with the API on WordPress.org?
Mike Schinkel
mikeschinkel at gmail.com
Sat Jan 3 22:51:41 GMT 2009
Hi all:
I've managed to get a very simple proof-of-concept of my RESTful API for
WordPress plugins online. It is based on a project I developed a year ago I
called RESTian (http://code.google.com/p/restian/) for which I had planned
to release the code but never found time. I was new to PHP then (although
with 10+ years prior experience on ASP) and looking at the code I somewhat
cringe now but it is working and I can always refactor!
As an aside, the key point of RESTian, btw, was to establish standard usage
patterns for URL design for RESTful services, to establish coding patterns
for implementing RESTful services that could transcend languages (i.e.
Python, Ruby, etc. in addition to PHP), and to provide standard modules for
both Javascript client and PHP/Python/Ruby/et al. server. Since then I've
decided to focus on PHP so I doubt I'd be the one to move anything forward
with Python or Ruby but the other goals remain.
Anyway, here is what I have working at the moment:
*List all plugins in text/html:
*
http://api.advancedwordpress.net/0.1/plugins.html
*List all plugins in application/json:
* http://api.advancedwordpress.net/0.1/plugins.json
*List all plugins in application/json but serve as text/plain mimetype:
* http://api.advancedwordpress.net/0.1/plugins.json?serve=txt
*List one plugin (in this case Akismet) in text/html:*
http://api.advancedwordpress.net/0.1/plugins/akismet.html
*List one plugin (in this case Akismet) **in application/json:
* http://api.advancedwordpress.net/0.1/plugins/akismet.json
*List one plugin (in this case Akismet) **in application/**json but serve as
text/plain mimetype:** *
http://api.advancedwordpress.net/0.1/plugins/akismet.json?serve=txt
It works quite well if I do say so myself. :-)
I could easily implement a serialized PHP response type but I want to
rearchitect the RESTian code to make it pluggable before I do that. Also,
does anyone know if there *is* a standardized PHP response type? If not,
there should be, no?
I could easily implement the ability to create subset like the following:
http://api.advancedwordpress.net/0.1/plugins/popular/
http://api.advancedwordpress.net/0.1/plugins/updated/
http://api.advancedwordpress.net/0.1/plugins/newest/
Or even searching (and the RSS mimetype):
http://api.advancedwordpress.net/0.1/plugins.html?q=Posts
http://api.advancedwordpress.net/0.1/plugins.json?q=Video
http://api.advancedwordpress.net/0.1/plugins.rss?q=Google+AdSense
You'll note that I versioned is 0.1 to indicate that it is very rough and
certainly not ready for primetime or nor should there be any expectation
that it will continue to work at this point so please no one go writing code
for it that you depend on. For one, I still need to think a lot more about
the URL design baked into RESTian and of course I need to refactor the
entire RESTian codebase. I will do my best to keep from breaking it but I
can't promise.
Any comments, questions, or suggestions will be appreciated.
That said, I'll soon come to the end of my free time to devote to this as I
start a major project on the 5th to last at least a month. We'll see if I
can move it forward during January but I can't promise.
-Mike Schinkel
http://mikeschinkel.com
More information about the wp-hackers
mailing list