From 2c525be865efe06088425369813240992e02b373 Mon Sep 17 00:00:00 2001 From: pepperpepperpepper Date: Thu, 8 Oct 2015 19:35:12 -0700 Subject: fixed a lot of things --- ricky/im.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ricky/im.py') diff --git a/ricky/im.py b/ricky/im.py index 715d825..159aa89 100644 --- a/ricky/im.py +++ b/ricky/im.py @@ -1,19 +1,23 @@ import urllib import urllib2 import sys -import random import simplejson as json -import urllib2 + class Im: def __init__(self): self._required_keys = [] self.url = "" + def post_request(self, url, params): params = urllib.urlencode(params) headers = { "Content-type": "application/x-www-form-urlencoded", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36", + "User-Agent":( + "Mozilla/5.0 (X11; Linux x86_64) " + "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/40.0.2214.94 Safari/537.36" + ), "Accept": "text/plain" } try: @@ -23,7 +27,8 @@ class Im: except Exception as e: sys.stderr.write(str(e)) raise + def call(self, params): if not(params.is_ready()): - raise Exception("Im Params Not Ready") + raise Exception("Im Params Not Ready") return json.loads(self.post_request(self.url, params.as_dict())) -- cgit v1.2.3-70-g09d2