Logic Colony
notes tags

Getting started with the Disqus API using Curl

Just a collection of notes from playing around with the Disqus API.

I will be using the curl command line tool on OSX Leopard. I have set up a Disqus account and associated a couple of websites with that account.

1: Get your User Key

Assuming you have created an account with Disqus and are logged in, you can get your user key (which you should keep private) here.

It's easiest to do this in the browser, so just go to that URL and save your user key somewhere safe. You'll be needing the user key for making some calls to the API, so keep it handy.

2: Escape your User Key so you can correctly use it with curl

An easy way to do this is to just enter the following in the URL bar of your browser:

javascript:escape("your user key here")

The browser will display the escaped version of your user key, and this is what you need to use when passing the parameter in any curl calls.

3: Invoke a method: get_forum_list

curl -i -L http://disqus.com/api/get_forum_list?userapikey=[your key here]

I've specified the -i option to get curl to output HTTP headers, and also the -L option to ensure curl will follow any HTTP redirects issued by the server.

Editted output from the above is:

Content-Length: 0

HTTP/1.1 200 OK Server: nginx/0.5.30 Date: Sat, 20 Sep 2008 16:14:36 GMT Content-Type: application/json Transfer-Encoding: chunked Connection: keep-alive Vary: Cookie,Accept-Encoding

{"message": [{"created_at": "2008-09-20 08:31:31.186839", "shortname": "xxxxxxxx", "id": "xxxxx", "name": "Logic Colony"}], "code": "ok", "succeeded": true}

Voila, we get the result of the method call back in the form of a load of JSON.

This is pretty much all you need to start exploring the Disqus API using curl. You also might find this guide to Using Curl to Automate HTTP Jobs helpful.

Krishna Kotecha


Tagged with: api curl disqus howto

Last edited on Saturday, 20 September 2008 at 16:48


© Logic Colony Limited, 2007 - 2008. All Rights Reserved.