getThreadList

This commit is contained in:
Taehoon Kim
2015-04-25 23:37:37 +09:00
parent bdbdaf120e
commit 9c1042f193
3 changed files with 22 additions and 5 deletions

View File

@@ -63,6 +63,10 @@ class Client(object):
if not self.login():
raise Exception("id or password is wrong")
self.threads = []
self.threads = []
self.data = data
def _console(self, msg):
if self.debug: print(msg)
@@ -192,7 +196,10 @@ class Client(object):
r = self._post("https://www.facebook.com/ajax/mercury/send_messages.php", form)
return r.ok
def getThreadList(self, start, end):
def getThreadList(self, start, end=None):
if not end:
end = start + 20
timestamp = now()
date = datetime.now()
data = {
@@ -206,11 +213,18 @@ class Client(object):
'inbox[offset]' : start,
'inbox[limit]' : end,
}
print data
r = self._post("https://www.facebook.com/ajax/mercury/threadlist_info.php", data)
self.r = r
return r.ok
if not r.ok:
return None
j = get_json(r.text)
for thread in j['payload']['threads']:
t = Thread(thread)
self.threads.append(t)
return self.threads
def sendSticker(self):
pass

View File

@@ -21,3 +21,6 @@ class User(Base):
self.data = data
class Thread():
def __init__(self, **entries):
self.__dict__.update(entries)

View File

@@ -15,7 +15,7 @@ def now():
return int(time()*1000)
def get_json(text):
return json.loads(re.sub(r"for.*(.*;.*;.*).*;", '', text.decode("unicode-escape").encode('utf-8')))
return json.loads(re.sub(r"for.*(;;).*;", '', text.decode("unicode-escape").encode('utf-8'), 1))
def digit_to_char(digit):
if digit < 10: