getThreadList
This commit is contained in:
@@ -63,6 +63,10 @@ class Client(object):
|
|||||||
if not self.login():
|
if not self.login():
|
||||||
raise Exception("id or password is wrong")
|
raise Exception("id or password is wrong")
|
||||||
|
|
||||||
|
self.threads = []
|
||||||
|
self.threads = []
|
||||||
|
self.data = data
|
||||||
|
|
||||||
def _console(self, msg):
|
def _console(self, msg):
|
||||||
if self.debug: print(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)
|
r = self._post("https://www.facebook.com/ajax/mercury/send_messages.php", form)
|
||||||
return r.ok
|
return r.ok
|
||||||
|
|
||||||
def getThreadList(self, start, end):
|
def getThreadList(self, start, end=None):
|
||||||
|
if not end:
|
||||||
|
end = start + 20
|
||||||
|
|
||||||
timestamp = now()
|
timestamp = now()
|
||||||
date = datetime.now()
|
date = datetime.now()
|
||||||
data = {
|
data = {
|
||||||
@@ -206,11 +213,18 @@ class Client(object):
|
|||||||
'inbox[offset]' : start,
|
'inbox[offset]' : start,
|
||||||
'inbox[limit]' : end,
|
'inbox[limit]' : end,
|
||||||
}
|
}
|
||||||
print data
|
|
||||||
|
|
||||||
r = self._post("https://www.facebook.com/ajax/mercury/threadlist_info.php", data)
|
r = self._post("https://www.facebook.com/ajax/mercury/threadlist_info.php", data)
|
||||||
self.r = r
|
if not r.ok:
|
||||||
return 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):
|
def sendSticker(self):
|
||||||
pass
|
pass
|
||||||
|
@@ -21,3 +21,6 @@ class User(Base):
|
|||||||
|
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
|
class Thread():
|
||||||
|
def __init__(self, **entries):
|
||||||
|
self.__dict__.update(entries)
|
||||||
|
@@ -15,7 +15,7 @@ def now():
|
|||||||
return int(time()*1000)
|
return int(time()*1000)
|
||||||
|
|
||||||
def get_json(text):
|
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):
|
def digit_to_char(digit):
|
||||||
if digit < 10:
|
if digit < 10:
|
||||||
|
Reference in New Issue
Block a user