Merge pull request #7 from wannaphongcom/master
Fix login and sendMessage
This commit is contained in:
@@ -15,7 +15,7 @@ from .client import *
|
||||
|
||||
|
||||
__copyright__ = 'Copyright 2015 by Taehoon Kim'
|
||||
__version__ = '0.0.2'
|
||||
__version__ = '0.0.3'
|
||||
__license__ = 'BSD'
|
||||
__author__ = 'Taehoon Kim'
|
||||
__email__ = 'carpedm20@gmail.com'
|
||||
|
@@ -65,7 +65,7 @@ class Client(object):
|
||||
|
||||
self.threads = []
|
||||
self.threads = []
|
||||
self.data = data
|
||||
|
||||
|
||||
def _console(self, msg):
|
||||
if self.debug: print(msg)
|
||||
@@ -155,7 +155,7 @@ class Client(object):
|
||||
for entry in j['payload']['entries']:
|
||||
if entry['type'] == 'user':
|
||||
users.append(User(entry))
|
||||
return users
|
||||
return users # have bug TypeError: __repr__ returned non-string (type bytes)
|
||||
|
||||
def sendMessage(self, message, thread_id):
|
||||
timestamp = now()
|
||||
@@ -193,7 +193,7 @@ class Client(object):
|
||||
'message_batch[0][has_attachment]' : False
|
||||
}
|
||||
|
||||
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", data)
|
||||
return r.ok
|
||||
|
||||
def getThreadList(self, start, end=None):
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import re
|
||||
import json
|
||||
from time import time
|
||||
|
||||
from random import random, choice
|
||||
USER_AGENTS = [
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36",
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/601.1.10 (KHTML, like Gecko) Version/8.0.5 Safari/601.1.10",
|
||||
@@ -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'), 1))
|
||||
return json.loads(re.sub(r"for.*(.*;.*;.*).*;", '', text.encode('utf-8').decode("unicode-escape"), 1))
|
||||
|
||||
def digit_to_char(digit):
|
||||
if digit < 10:
|
||||
@@ -34,4 +34,3 @@ def generateMessageID(client_id=None):
|
||||
k = now()
|
||||
l = int(random() * 4294967295)
|
||||
return ("<%s:%s-%s@mail.projektitan.com>" % (k, l, client_id));
|
||||
|
||||
|
1
setup.py
1
setup.py
@@ -57,6 +57,7 @@ setup(
|
||||
'Programming Language :: Python :: 3.3',
|
||||
'Programming Language :: Python :: 3.3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
'Programming Language :: Python',
|
||||
|
Reference in New Issue
Block a user