diff --git a/.gitignore b/.gitignore index f429dd3..2345f05 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ my_tests.py my_test_data.json my_data.json tests.data + +# Virtual environment +venv/ diff --git a/fbchat/__init__.py b/fbchat/__init__.py index 329459d..67ef0a9 100644 --- a/fbchat/__init__.py +++ b/fbchat/__init__.py @@ -17,7 +17,7 @@ from .client import * __copyright__ = 'Copyright 2015 - {} by Taehoon Kim'.format(datetime.now().year) -__version__ = '1.3.6' +__version__ = '1.3.7' __license__ = 'BSD' __author__ = 'Taehoon Kim; Moreels Pieter-Jan; Mads Marquart' __email__ = 'carpedm20@gmail.com' diff --git a/fbchat/client.py b/fbchat/client.py index 3e648c5..2b20d69 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -217,7 +217,7 @@ class Client(object): else: self.fb_dtsg = re.search(r'name="fb_dtsg" value="(.*?)"', r.text).group(1) - + fb_h_element = soup.find("input", {'name':'h'}) if fb_h_element: self.fb_h = fb_h_element['value'] @@ -337,7 +337,7 @@ class Client(object): """ # Send a request to the login url, to see if we're directed to the home page r = self._cleanGet(self.req_url.LOGIN, allow_redirects=False) - return 'home' in r.headers['Location'] + return 'Location' in r.headers and 'home' in r.headers['Location'] def getSession(self): """Retrieves session cookies diff --git a/tests.py b/tests.py index 033a259..caf6748 100644 --- a/tests.py +++ b/tests.py @@ -114,7 +114,7 @@ class TestFbchat(unittest.TestCase): self.assertIsNotNone(client.send(Message(sticker=Sticker(test_sticker_id)))) def test_sendImages(self): - image_url = 'https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-image-128.png' + image_url = 'https://github.com/carpedm20/fbchat/raw/master/tests/image.png' image_local_url = path.join(path.dirname(__file__), 'tests/image.png') for thread in threads: client.setDefaultThread(thread_id=thread['id'], thread_type=thread['type'])