Skip to content

Instantly share code, notes, and snippets.

@robhudson
Created October 5, 2009 23:39
Show Gist options
  • Save robhudson/202599 to your computer and use it in GitHub Desktop.
Save robhudson/202599 to your computer and use it in GitHub Desktop.
Super minimal Disqus API client
"""Super minimal Disqus API client"""
import urllib
try:
import json
except ImportError:
import simplejson as json
class DisqusClient(object):
def __init__(self, user_api_key, method=None):
self.user_api_key = user_api_key
self.method = method
def __getattr__(self, method):
return DisqusClient(self.user_api_key, method)
def __call__(self, **params):
params['user_api_key'] = self.user_api_key
url = ("http://disqus.com/api/%s/?" % self.method) + urllib.urlencode(params)
f = urllib.urlopen(url)
return json.loads(f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment