agermanidis / SnapchatBot

[deprecated] Python library for building bots that live on Snapchat
MIT License
518 stars 105 forks source link

400 Client Error: Bad Request on Linux #4

Closed jczimm closed 9 years ago

jczimm commented 9 years ago

> python examples/connectorbot.py fails for me on CentOS 7.0 x64:

[2015-02-19 19:50:48,297] Starting new HTTPS connection (1): feelinsonice-hrd.appspot.com
[2015-02-19 19:50:48,573] "POST /bq/login HTTP/1.1" 200 None
[2015-02-19 19:50:48,582] Starting new HTTPS connection (1): feelinsonice-hrd.appspot.com
[2015-02-19 19:50:48,771] "POST /bq/updates HTTP/1.1" 400 None
Traceback (most recent call last):
  File "strangerbot.py", line 53, in <module>
    bot = ConnectorBot(args.username, args.password)
  File "build/bdist.linux-x86_64/egg/snapchat_bots/bot.py", line 21, in __init__
  File "build/bdist.linux-x86_64/egg/snapchat_bots/bot.py", line 75, in get_friends
  File "build/bdist.linux-x86_64/egg/pysnap/__init__.py", line 270, in get_friends

  File "build/bdist.linux-x86_64/egg/pysnap/__init__.py", line 125, in get_updates

  File "build/bdist.linux-x86_64/egg/pysnap/__init__.py", line 83, in _request

  File "build/bdist.linux-x86_64/egg/pysnap/utils.py", line 88, in request
  File "/usr/lib/python2.7/site-packages/requests-2.5.1-py2.7.egg/requests/models.py", line 831, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request
agermanidis commented 9 years ago

I've seen that 400 error on /bq/updates only when the username and password combination I used was wrong. Can you double check that you're using the right credentials? Thanks!

jczimm commented 9 years ago

I tried it again with a different account of which I also double-checked the credentials, and the problem persisted.

Note: the same script worked on my Windows 8 with cygwin toolkit.

jczimm commented 9 years ago

If I may ask, on what OS are you developing/testing this code?

agermanidis commented 9 years ago

I'm using OS X 10.10 on a Macbook Pro. Interesting that the request breaks on CentOS but works on cygwin. Don't have many guesses on what may be the problem. Can you try using SnapchatBot without passing the username + pass as command-line arguments, e.g.:

from snapchat_bots import SnapchatBot
bot = SnapchatBot("<your username>", "<your password>")
jczimm commented 9 years ago

That's not working for me either... I have a feeling the problem might have to do with how the request(s) are being sent, as I'm trying to run this on a VPS.

N07070 commented 9 years ago

Same here. It seems to have something to do with the request module of python.

EDIT: Bad password/user use, fixed it.

krissrex commented 9 years ago

Check if your account is locked. Using a low timeout, like 5, sets of the Snapchat anti-bot detection. Go to snapchat.com/unlock and try to unlock you account.

jczimm commented 9 years ago

I tried increasing the timeout, and I also tried unlocking the account. It still doesn't run right on my VPS, but it works perfectly fine locally. Might the problem be with /bq/updates?

daniel-sanche commented 9 years ago

I'm having the same issue. I tried posting to my story through the app, but it won't even post there. All other snapchat functions work fine, but not stories. I was using the storifier bot, I wonder if Snapchat disabled my account. (that unlock link didn't help)

N07070 commented 9 years ago

May I suggest making another snapchat account to try ? Edit : Also, could you state

jczimm commented 9 years ago

@N07070: Tried the same with a new account (to no avail).

N07070 commented 9 years ago

Try with pip udpate Pillow and man ffmpeg and man imagemagick. I have the Python 2.7.3, so you're more up to date... Altough, I'm running Debian.

danwatco commented 9 years ago

I am having the same problem as @jczimm Any help appreciated!

jczimm commented 9 years ago

Thanks @Samze! And I know why it doesn't work now. :disappointed:

Authorization Failed, status: "403" , message "The network you are connected to has been temporarily blocked because of suspicious activity"
danwatco commented 9 years ago

@jczimm I got the same message! Any idea how to fix? I still have access to internet, so don't see a problem

jczimm commented 9 years ago

@danwatco I got this error because I was trying to run it from a VPS, which was blocked by Snapchat. Where/what are you trying to run your bot from?

danwatco commented 9 years ago

@jczimm I was running a vps too, I had to recreate one with a different location/ip and now it works!

jczimm commented 9 years ago

@danwatco Oh ok, but how can you be sure that the new VPS won't get blocked? Just wondering, because it's a bit of work for me to recreate the VPS on a new IP.

danwatco commented 9 years ago

@jczimm I can't be :/ But it will have to do for now

agermanidis commented 9 years ago

I would guess that the higher the listen timeout, the less likely you are to get blocked, so use a large value to make sure that you won't be. 

On Sat, Feb 28, 2015 at 3:14 PM, Dan notifications@github.com wrote:

@jczimm I can't be :/ But it will have to do for now

Reply to this email directly or view it on GitHub: https://github.com/agermanidis/SnapchatBot/issues/4#issuecomment-76543699

jczimm commented 9 years ago

@agermanidis Oh ok. How long is a realistic timeout (realistic to seem like the app)? On Sat, Feb 28, 2015 at 9:02 PM Anastasis Germanidis < notifications@github.com> wrote:

I would guess that the higher the listen timeout, the less likely you are to get blocked, so use a large value to make sure that you won't be.

— Sent from Mailbox

On Sat, Feb 28, 2015 at 3:14 PM, Dan notifications@github.com wrote:

@jczimm I can't be :/ But it will have to do for now

Reply to this email directly or view it on GitHub:

https://github.com/agermanidis/SnapchatBot/issues/4#issuecomment-76543699

— Reply to this email directly or view it on GitHub https://github.com/agermanidis/SnapchatBot/issues/4#issuecomment-76563662 .

N07070 commented 9 years ago

I set it to 45 seconds. And you ?

PhlexPlexico commented 9 years ago

Reporting in with the same issue here. Every bot I try within the examples gives me error 400. Account is unlocked, and everything on that end is running. Using windows 7, python, cygwin, imagemagick etc installed to latest versions that I could find.

[2015-03-03 22:52:18,009] Starting new HTTPS connection (1): feelinsonice-hrd.ap
pspot.com
[2015-03-03 22:52:18,828] "POST /bq/login HTTP/1.1" 400 None
Traceback (most recent call last):
  File "reflectorbot.py", line 22, in <module>
    bot = ReflectorBot(args.username, args.password)
  File "build\bdist.win32\egg\snapchat_bots\bot.py", line 20, in __init__
  File "build\bdist.win32\egg\pysnap\__init__.py", line 100, in login
  File "build\bdist.win32\egg\pysnap\__init__.py", line 83, in _request
  File "build\bdist.win32\egg\pysnap\utils.py", line 88, in request
  File "C:\Python27\lib\site-packages\requests-2.5.3-py2.7.egg\requests\models.p
y", line 831, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request

Timeout set to 30 seconds, as well. Tried two different accounts and even hardcoded username and pass.