meta-ai-api icon indicating copy to clipboard operation
meta-ai-api copied to clipboard

Location error

Open applemuncy opened this issue 1 year ago • 1 comments

Maybe this is just a simple error that I can fix myself by reading to code more closely. Made a fresh Facebook account without two factor authentication. It seems to succeed logging in to Facebook from both Toronto CA and Columbus IN USA But then fails here.

Traceback (most recent call last): File "/home/alpha/second.py", line 3, in ai = MetaAI( fb_email="XXXXXXXXX", fb_password="XXXXXXX" ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/alpha/.venv/lib/python3.11/site-packages/meta_ai_api/main.py", line 50, in init self.cookies = self.get_cookies() ^^^^^^^^^^^^^^^^^^ File "/home/alpha/.venv/lib/python3.11/site-packages/meta_ai_api/main.py", line 316, in get_cookies fb_session = get_fb_session(self.fb_email, self.fb_password) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/alpha/.venv/lib/python3.11/site-packages/meta_ai_api/utils.py", line 210, in get_fb_session next_url = response.headers["Location"] ~~~~~~~~~~~~~~~~^^^^^^^^^^^^ File "/home/alpha/.venv/lib/python3.11/site-packages/requests/structures.py", line 52, in getitem return self._store[key.lower()][1] ~~~~~~~~~~~^^^^^^^^^^^^^ KeyError: 'location'

applemuncy avatar May 27 '24 21:05 applemuncy

'Location' rather than 'location'

omkarxpatel avatar Jul 26 '24 18:07 omkarxpatel

Hi, I spent some time today and fixed the login mechanism. Please upgrade to the latest version and try again on your end.

pip install meta-ai-api --upgrade

Example usage:

from meta_ai_api import MetaAI

ai = MetaAI(fb_email="EMAIL", fb_password="PASS")
resp = ai.prompt(message="Generate a flying corgi", stream=False)
print(resp)

Results to:

{'message': '\n', 'sources': [], 'media': [{'url': 'https://scontent-sjc3-1.xx.fbcdn.net/o1/v/t0/f1/m340/genai_m4_rva_prn_v3:upload_img_30150162_11_11_2024_15_38_53_839707_7210860893543658686.jpeg?_nc_ht=scontent-sjc3-1.xx.fbcdn.net&_nc_cat=105&ccb=9-4&oh=00_AYDdYcFmk3NE2fvIyRdfa1zplSNNUUKbdsKdY7nFtYMvjA&oe=67348AD2&_nc_sid=5b3566', 'type': 'IMAGE', 'prompt': 'a flying corgi'}, {'url': 'https://scontent-sjc3-1.xx.fbcdn.net/o1/v/t0/f1/m340/genai_m4_rva_ftw_v3:upload_img_80186289_11_11_2024_15_38_53_877200_5339600777371350444.jpeg?_nc_ht=scontent-sjc3-1.xx.fbcdn.net&_nc_cat=108&ccb=9-4&oh=00_AYCjw3uIocVsooGRlB6N27QYGQK93WlyaBCS5fhiShwTtA&oe=67346269&_nc_sid=5b3566', 'type': 'IMAGE', 'prompt': 'a flying corgi'}, {'url': 'https://scontent-sjc3-1.xx.fbcdn.net/o1/v/t0/f1/m340/genai_m4_rva_frc_v3:upload_img_1123599_11_11_2024_15_38_53_891297_2220685283103798415.jpeg?_nc_ht=scontent-sjc3-1.xx.fbcdn.net&_nc_cat=108&ccb=9-4&oh=00_AYAb7QbUyaTye_HxF0V1qz9yK5_1f-_cYSeERSKVs4h0OQ&oe=673479BE&_nc_sid=5b3566', 'type': 'IMAGE', 'prompt': 'a flying corgi'}, {'url': 'https://scontent-sjc3-1.xx.fbcdn.net/o1/v/t0/f1/m340/genai_m4_ncg_odn_v3:upload_img_438087_11_11_2024_15_38_53_922254_6380853868722563899.jpeg?_nc_ht=scontent-sjc3-1.xx.fbcdn.net&_nc_cat=108&ccb=9-4&oh=00_AYByFV4a_fjrPeHX8lcs2EyhGP4X4NQByFO7LYFh-I_63A&oe=67348268&_nc_sid=5b3566', 'type': 'IMAGE', 'prompt': 'a flying corgi'}]}

Flying Corgi

Strvm avatar Nov 11 '24 23:11 Strvm