#!/usr/bin/env python # -*- coding: iso-8859-1 -*- from google.appengine.api.urlfetch import fetch from django.utils.simplejson import loads, dumps import re class AnyClipBackoffice(): def __init__(self, key): self.key = key self.errorMatch = re.compile("(.*)(.*)") def request(self, *arguments, **keywords): keywords["token"] = self.key url = "http://api.anyclip.com/ac_backoffice/v1/json/" for call in arguments: url += call + "/" response = fetch(url, payload=dumps(keywords), method="POST", headers={"Content-Type": "application/json; charset=utf-8"}) if response.status_code == 200: error = self.errorMatch.search(response.content) if error != None: return None else: return loads(response.content) else: return None