Created
October 5, 2009 23:39
-
-
Save robhudson/202599 to your computer and use it in GitHub Desktop.
Super minimal Disqus API client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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