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

KeyError: "name='xs', domain=None, path=None"

Open RexsyBima opened this issue 1 year ago • 12 comments

when i ran the code from either python or jupiter notebook with these lines

from meta_ai_api import MetaAI

ai = MetaAI(fb_email="someemail", fb_password="somepassword")
response = ai.prompt(message="Whats the weather in San Francisco today? And what is the date?")
print(response)

i got


Traceback (most recent call last):
  File "d:\Python\metaaitest\main.py", line 185, in <module>
    funcGenNews(news)
  File "d:\Python\metaaitest\main.py", line 92, in funcGenNews
    ai = CustomMetaAI()
  File "d:\Python\metaaitest\src\meta_ai.py", line 19, in __init__
    super().__init__(fb_email=fb_email, fb_password=fb_password)
  File "D:\Python\tiktok-content-news-AI\.venv\lib\site-packages\meta_ai_api\main.py", line 50, in __init__
    self.cookies = self.get_cookies()
  File "D:\Python\metaaitest\.venv\lib\site-packages\meta_ai_api\main.py", line 316, in get_cookies
    fb_session = get_fb_session(self.fb_email, self.fb_password)
  File "D:\Python\metaaitest\.venv\lib\site-packages\meta_ai_api\utils.py", line 157, in get_fb_session
    "xs": session.cookies["xs"],
  File "D:\Python\metaaitest\.venv\lib\site-packages\requests\cookies.py", line 334, in __getitem__
    return self._find_no_duplicates(name)
  File "D:\Python\metaaitest\.venv\lib\site-packages\requests\cookies.py", line 413, in _find_no_duplicates
    raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}")
KeyError: "name='xs', domain=None, path=None"

im using vpn to avoid region block, yesterday was fine as butter. idk why it happens

RexsyBima avatar May 13 '24 12:05 RexsyBima

Hi, are you able to access it with your VPN on a browser?

Strvm avatar May 13 '24 16:05 Strvm

Yup i can, im using windscribe

RexsyBima avatar May 13 '24 16:05 RexsyBima

Yup i can, im using windscribe

And could you try without authenticating and tell me what do you get

Strvm avatar May 13 '24 16:05 Strvm

i got

Exception: Unable to obtain a valid response from Meta AI. Try again later.

just want to make sure, is it still working on your end?

RexsyBima avatar May 13 '24 17:05 RexsyBima

i got

Exception: Unable to obtain a valid response from Meta AI. Try again later.

just want to make sure, is it still working on your end?

Yep it works fine on my end, without a VPN (I'm in the US)

ai = MetaAI()
print(ai.prompt(message=f"Say this is a test 1"))
{'message': "Test 1 Successful! This is a test indeed! I'm ready to assist you with any questions or tasks you have. What's next?\n", 'sources': [], 'media': []}

Strvm avatar May 13 '24 17:05 Strvm

im kinda worried it has something to do with my account, i did something in my facebook app which is that i created new fan page profile... ill try to create dummy fresh facebook account just in case, but not now, will try to do it tomorrow

RexsyBima avatar May 13 '24 17:05 RexsyBima

Not sure it has anything to do with your FB account since it should also work without authenticating

Strvm avatar May 13 '24 17:05 Strvm

what python version are you using?

RexsyBima avatar May 13 '24 17:05 RexsyBima

The test was running 3.8, but that shouldn't really matter

Strvm avatar May 13 '24 17:05 Strvm

so i use some dummy facebook account here, same code, but now i got KeyError instead

Traceback (most recent call last):
  File "d:\Python\meta-ai-api\test.py", line 3, in <module>
    ai = MetaAI(fb_email="xxxx", fb_password="xxxx")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\meta-ai-api\.venv\Lib\site-packages\meta_ai_api\main.py", line 50, in __init__
    self.cookies = self.get_cookies()
                   ^^^^^^^^^^^^^^^^^^
  File "D:\Python\meta-ai-api\.venv\Lib\site-packages\meta_ai_api\main.py", line 316, in get_cookies
    fb_session = get_fb_session(self.fb_email, self.fb_password)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\meta-ai-api\.venv\Lib\site-packages\meta_ai_api\utils.py", line 210, in get_fb_session
    next_url = response.headers["Location"]
               ~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "D:\Python\meta-ai-api\.venv\Lib\site-packages\requests\structures.py", line 52, in __getitem__
    return self._store[key.lower()][1]
           ~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'location'

RexsyBima avatar May 13 '24 17:05 RexsyBima

Update for this, turns out Meta doesnt allow some dummy account to be using Meta.AI, kinda an L, when i access meta.ai manually using dummya account to login, i got kicked out from login page but there is notification what went wrong, therefore i assume it because i have this dummy account

so i use some dummy facebook account here, same code, but now i got KeyError instead

Traceback (most recent call last):
  File "d:\Python\meta-ai-api\test.py", line 3, in <module>
    ai = MetaAI(fb_email="xxxx", fb_password="xxxx")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\meta-ai-api\.venv\Lib\site-packages\meta_ai_api\main.py", line 50, in __init__
    self.cookies = self.get_cookies()
                   ^^^^^^^^^^^^^^^^^^
  File "D:\Python\meta-ai-api\.venv\Lib\site-packages\meta_ai_api\main.py", line 316, in get_cookies
    fb_session = get_fb_session(self.fb_email, self.fb_password)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\meta-ai-api\.venv\Lib\site-packages\meta_ai_api\utils.py", line 210, in get_fb_session
    next_url = response.headers["Location"]
               ~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "D:\Python\meta-ai-api\.venv\Lib\site-packages\requests\structures.py", line 52, in __getitem__
    return self._store[key.lower()][1]
           ~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'location'

RexsyBima avatar May 13 '24 18:05 RexsyBima

i got Exception: Unable to obtain a valid response from Meta AI. Try again later. just want to make sure, is it still working on your end?

Yep it works fine on my end, without a VPN (I'm in the US)

ai = MetaAI()
print(ai.prompt(message=f"Say this is a test 1"))
{'message': "Test 1 Successful! This is a test indeed! I'm ready to assist you with any questions or tasks you have. What's next?\n", 'sources': [], 'media': []}

Wait, can you try to do the same thing but with facebook login feature enabled? the only way i can get into it working before it bugged out is that i have to use login to the facebook feature

RexsyBima avatar May 13 '24 18:05 RexsyBima