added getUserInfo to fix #47

This commit is contained in:
thekindlyone
2016-08-29 15:03:16 +05:30
parent 3025c032fe
commit 05f7b2cd42

View File

@@ -25,7 +25,6 @@ from .stickers import *
# URLs # URLs
LoginURL ="https://m.facebook.com/login.php?login_attempt=1" LoginURL ="https://m.facebook.com/login.php?login_attempt=1"
SearchURL ="https://www.facebook.com/ajax/typeahead/search.php" SearchURL ="https://www.facebook.com/ajax/typeahead/search.php"
# SendURL ="https://www.facebook.com/ajax/mercury/send_messages.php"
SendURL ="https://www.facebook.com/messaging/send/" SendURL ="https://www.facebook.com/messaging/send/"
ThreadsURL ="https://www.facebook.com/ajax/mercury/threadlist_info.php" ThreadsURL ="https://www.facebook.com/ajax/mercury/threadlist_info.php"
ThreadSyncURL="https://www.facebook.com/ajax/mercury/thread_sync.php" ThreadSyncURL="https://www.facebook.com/ajax/mercury/thread_sync.php"
@@ -38,7 +37,7 @@ MobileURL ="https://m.facebook.com/"
StickyURL ="https://0-edge-chat.facebook.com/pull" StickyURL ="https://0-edge-chat.facebook.com/pull"
PingURL ="https://0-channel-proxy-06-ash2.facebook.com/active_ping" PingURL ="https://0-channel-proxy-06-ash2.facebook.com/active_ping"
UploadURL ="https://upload.facebook.com/ajax/mercury/upload.php" UploadURL ="https://upload.facebook.com/ajax/mercury/upload.php"
UserInfoURL ="https://www.facebook.com/chat/user_info/"
class Client(object): class Client(object):
"""A client for the Facebook Chat (Messenger). """A client for the Facebook Chat (Messenger).
@@ -549,6 +548,21 @@ class Client(object):
except requests.exceptions.Timeout: except requests.exceptions.Timeout:
pass pass
def getUserInfo(self,user_ids):
"""Get user info from id.
:param user_ids: list of or one user id(s) to query
"""
if type(user_ids) != list:
user_ids=[user_ids]
data = {"ids[{}]".format(i):user_id for i,user_id in enumerate(user_ids)}
r = self._post(UserInfoURL, data)
return get_json(r.text)
def on_message(self, mid, author_id, author_name, message, metadata): def on_message(self, mid, author_id, author_name, message, metadata):
''' '''