Monthly Archives: April 2012

REST API for WordPress

“Everything should be made as simple as possible, but not simpler.” A. Einstein

It is not that much I started tinkering about WordPress, and they publish a very interesting API for the site.
Following a well-established path, the site is a REST one. I would like to develop some code around it.
For now I show a very little snippet, in Python:

import urllib2
f = urllib2.urlopen('http://public-api.wordpress.com/rest/v1/sites/33534099/posts/43/?pretty=true/')
print f.read(100000)

If you own a nice copy of Python on your PC (that I warmly suggest), you can just call it with the simple
python
command. In the python environment you can then copy and paste the previous snippet, a row at a time, or you can create a file and make python execute it.
The result is a JSON description of data. What is Jason? We’ll see sooner or later: for now, let’s define it as a means to describe an object in a very direct manner.
For today please just observe the REST-ivity 🙂 of the call. If you look at the URL, you can clearly understand the structure of the request: it is a hierarchical description of something you want to GET.
It’s not by chance I am using the word “GET”: with REST you return to the very beginning of HTTP, (W3C specs) using just GET, POST, DEL and (guess!) PUT as basic verbs. Talking deeply about that would take us very far, for the moment let’s admire the clarity of the call.

Advertisements

Dropbox enlarges!

These are a few of my favorite things!” – The Sound of Music

I find Dropbox very useful. I started using it almost three years ago, and I use it a lot, for private and professional aims. It makes a copy in the cloud of the whole content of a directory of your computer. But that’s not all. If you want, it can replicate and align it on every machine you like. The power of cloud!

That means that every change you make on a file in whichever PC, it will be (almost) instantly replicated in the cloud – and into the other machines you enabled. Not only, you can decide to share a subdirectory with everybody you want.

So you can use it

  • for backup
  • to align those very useful documents you need both at home and in the office, or travelling
  • to share documents among people working on the same job

In the free version, it offers you a month versioning of every changed copy of every file. So (inside this span of time) you can recover deleted copies or old versions of your files.

In the past I used USB pens, mail, FTP sites and so on when I had to synchronize files between my office PC and the home one. It was really an hassle. Now everything goes smooth.

And now the news.

They gave you 2 GB of free space in the cloud, and a 250 MB bonus for each person you convince to use it – until now. Just today they sent me a notice to inform me that the bonuses are – retroactively – doubled. So instead of 6 GB (2 initial dimension + 4 gained by spreading the info around) I have now 10 GB of free space!

The Sound of Music.