fbchat-dev / fbchat

Facebook Chat (Messenger) for Python
https://fbchat.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.19k stars 411 forks source link

Error #1390008 with fetchUserInfo #511

Open M0nochrome opened 4 years ago

M0nochrome commented 4 years ago

I don't think this is an issue with fbchat but I can't really ask it anywhere else, so here goes: I've made a simple program that basically looked at all the messages of a group chat one by one and fetched information about its user, it was working great while I was testing it, but once I let it run for the whole conversation which took about an hour it returned with the following error at the point where I call "fetchUserInfo":

Traceback (most recent call last):
  File "C:\Users\monochrome\Desktop\testpyth\PythonApplication1\PythonApplication1\new.py", line 28, in <module>
    user = client.fetchUserInfo('11111')
  File "C:\Users\monochrome\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\_client.py", line 621, in fetchUserInfo
    threads = self.fetchThreadInfo(*user_ids)
  File "C:\Users\monochrome\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\_client.py", line 721, in fetchThreadInfo
    pages_and_users = self._fetchInfo(*pages_and_user_ids)
  File "C:\Users\monochrome\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\_client.py", line 571, in _fetchInfo
    j = self._payload_post("/chat/user_info/", data)
  File "C:\Users\monochrome\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\_client.py", line 116, in _payload_post
    return self._state._payload_post(url, data, files=files)
  File "C:\Users\monochrome\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\_state.py", line 261, in _payload_post
    j = self._post(url, data, files=files)
  File "C:\Users\monochrome\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\_state.py", line 246, in _post
    _util.handle_payload_error(j)
  File "C:\Users\monochrome\AppData\Local\Programs\Python\Python37\lib\site-packages\fbchat\_util.py", line 146, in handle_payload_error
    fb_error_message=j["errorDescription"],
fbchat._exception.FBchatFacebookError: Error #1390008 when sending request: {'__html': '<ul class="uiList _4kg _6-h _6-j _6-i"><li>We limit how often you can post, comment or do other things in a given amount of time in order to help protect the community from spam. You can try again later. <a href="https://www.facebook.com/help/177066345680802">Learn More</a></li><li>If you think this doesn&#039;t go against our Community Standards <a href="https://www.facebook.com/help/contact/571927962827151?additional_content=Aeje2lKJzTTJz_O-izhGbTW4SXGwxnm8jogK3Csi_TtDa-nNy0LwHnWLtTEEaBjx8VSDiqqBmmM38-0Vl9ZWY_xhSJabrjq7B6UfBjE58lMk6kb6X0T51cwmasqDq-i-upzR7b8mji_VJn7NZZZctmJ0EMKSMoi5QrWhEW3HYg1it8JCd9oN2N2QaJlMjRa58HHcAHbBK5sG-WyG1_DwlgJu3oafbv5W0uGicycaBaWLkuPFYv42NoOCj3lMoHdk2piSfn-Xlm0kPQj2wejBzCT6LXYmDYtRT70h9563x2F9uecjZV4F6oRnCK6cCGLPMFC69Oyk9aBB0M8kR9WWQhj-DtRd1KlElxWKbXpgBN4zpGAC5bJZWTC68n_6ohh98UedaAnwKWvMDPSoyDXYEneB1H8f0_Nz05OWiapPN_mDVZTGmVX6dhScCtqJ4YmchZ5PEtZeYneBRIws7awsgSsN9DBKaWjzbxA0cRaUwd4amrj_H2uXxArjqlqq7D5RLFRvhJSIsb89_2eLehunRkNj7AmP63_Sg_M2kKJPMOk5gQ" target="_blank">let us know</a>.</li></ul>'}

It's been a day since and I still can't use fetchUserInfo. Weirdly enough though, I can use normally other fetch requests (such as fetchThreadMessages) and even send messages, also I'm not banned from facebook/messenger, I can still use them fine, so I don't know what's going on. Any help would be appreciated?

madsmtm commented 4 years ago

Hmm, not really sure I can help you get unblocked, but I seem to remember that when I've gotten blocked, it usually takes ~24 or more hours before I'm unblocked, and in that time, I'm not allowed to do anything (or the timer resets). So taking a day, or maybe three, might be a solution, but don't count on it šŸ˜•.

Another thing: If you do find out how to get unblocked, and you want it to stay that way, you should batch your requests to fetchUserInfo, by providing multiple ids at once:

user_ids = ['11111', '22222', '33333', '44444']
users = client.fetchUserInfo(*user_ids)

And a third thing: Perhaps I misread, but it sounds like you just want to fetch the group's participants? That can be done quite easily with Group.participants:

group = c.fetch_group_info(group_id)[group_id]
users = client.fetchUserInfo(*group.participants)
M0nochrome commented 4 years ago

Hm, I'll wait a bit more. It's been more than 40 hours since the error. Still though, I don't get how I am "blocked" but can do anything else BUT fetchUserInfo. Does fb block you from specific requests that you "abused"? Once I get unblocked should I delay my requests by say 1 sec or is there a limit per day or it doesn't matter and it's just luck whether facebook will notice you?

If you do find out how to get unblocked, and you want it to stay that way, you should batch your requests

You're right, I should do that. I hadn't given it much thought and had fetchUserInfo in a loop for no reason at all.

madsmtm commented 4 years ago

Can't answer your questions, sorry, I simply don't know šŸ˜•. Good luck!