Closed enstulen closed 9 years ago
Same error
I'm getting that too as of last night
Yeah, this has to do with the host. This is not a coding mistake, even considering that it was working for you last night. I think we'll have to wait for the owner's note on this but this is either the host acting up or Snapchat could have blocked all requests from this host.
The host feelinsonice-hrd.appspot.com
is snapchat's server though.
I get the impression they're doing a big sweep on bots
When snapchat block an unofficial API, what it's really affected on the code ? The headers ?
@ricoxor I actually don't know. Thinking about what ObjectiveTruth said, which for some reason cleared up a lot of things or I was just had temporary confusion, it'd be our entire request. Headers included, user agent, some how Snapchat is knowing that when we run it is a bot. I'm going to look more into this because I'm interested in fixing it so I may end up forking.
@Sh1eld, I just forked it and I'm working on adding some entropy to all the calls using random.uniform(5.0, 45.0)
but I think you're right about the headers. Might have to go more low level on it.
To be banned so quickly must be something systematically obvious.
This API work fine, you can check the headers and user agent if you want.
https://github.com/mgp25/Snap-API
See getGCMToken()
and getAuthToken()
in Snapchat.php
@ricoxor , when you say it works fine, have you tried running the PHP script in a vacuum? or you saying from looking at the source?
There's an open issue from 5 days ago about unauthorized access on the very first call using the API https://github.com/mgp25/Snap-API/issues/2 related?
This API work fine this morning (i need to try for now). This is the last working API for me
Haha, I see we're going down the same rabbit hole, I see your comments in a few places.
I'm getting my environment setup now to run that Snap-API, I'll let you know what I find. Hopefully that works and we can start from there
Same error.
Traceback (most recent call last):
File "./storyfbbot-dev.py", line 37, in <module>
bot = derp('d', 'd')
File "/home/n07070/Code/SnapchatBot/snapchat_bots/bot.py", line 20, in __init__
result = self.client.login(username, password)
File "build/bdist.linux-i686/egg/pysnap/__init__.py", line 100, in login
File "build/bdist.linux-i686/egg/pysnap/__init__.py", line 83, in _request
File "build/bdist.linux-i686/egg/pysnap/utils.py", line 88, in request
File "/usr/local/lib/python2.7/dist-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
@ObjectiveTruth what are you doing with random.uniform()
? Where are you adding that to the call?
@Rob-- Haven't done it yet, but was thinking before each call back. What do you think?
def listen(self, timeout=/DEFAULT_TIMEOUT):
while True:
self.log("Querying for new snaps...")
snaps = self.get_snaps()
if hasattr(self, "on_snap"):
for snap in snaps:
self.on_snap(snap.sender, snap)
added_me = self.get_added_me()
newly_added = set(added_me).difference(self.added_me)
newly_deleted = set(self.added_me).difference(added_me)
self.added_me = added_me
if hasattr(self, "on_friend_add"):
for friend in newly_added:
self.log("User %s added me" % friend)
self.on_friend_add(friend)
if hasattr(self, "on_friend_delete"):
for friend in newly_deleted:
self.log("User %s deleted me" % friend)
self.on_friend_delete(friend)
random.uniform(5.0, 45.0)
time.sleep(timeout)
@ObjectiveTruth
The documentation for random.uniform(a, b)
is:
Return a random floating point number N such that a <= N <= b for a <= b and b <= N <= a for b < a.
So you've added the line random.uniform(5.0, 45.0)
, isn't this line effectively useless? It returns a number but you're not passing it as a parameter anywhere.
Is your intention to generate a random integer and make the program sleep for that amount of time?
Yeah that's what I mean, was in a middle of a few things, forgot to pass it in, but yes that's the intention
P.S. I'm going to save that comment, that's probably the most diplomatic way of saying, "your code does nothing" lol
@ObjectiveTruth
Well that's easy to do:
time.sleep(timeout + random.uniform(5.0, 45.0))
The only problem is here, and I'm sure others will agree with me, is that I doubt Snapchat are looking at the intervals at which you send your requests. I think it comes down to looking at the parameters and headers that are passed on during the POST
requests.
@Rob-- Alright
Do we have any solutions ? How could I help ?
Okay! I think I've done it! I implemented loq
(replacing bq
) and it was a successful request - hell of a successful request, it returned like 5 pages of information. I think this means I might need to document loq
for future use.
Basically, because this information was returned it means I was able to successfully login - which means it wasn't a bad request. The downside to all of this is that I receive 400 status codes when trying to use the old API's endpoints (such as /bq/updates
). Essentially this means I need to update this entire library to use the new endpoints of the API.
I think this means I'll need to develop a new library using the updated API as this library has been rendered unusable (unless someone can find a fix).
I still don't know why we can't use the old endpoints as people's devices use them - unless they've completely banned bq
, which I doubt they have, then Snapchat are able to identify us as bots. I'm not sure how they do this as this library's requests are properly formed.
I don't think this has to do with Snapchat identifying us as bots, I had my bot shut off for a few weeks now, and when I turned it back on today I got this error.
@Rob-- Hmm, okay. I can help developing the updated library and I believe that this will be better in the long run anyways considering us using /bq/ was a stretch. Using the new endpoints will be updated and provide more functionality. I
Just pushed a very hacky hotfix that makes SnapchatBot use /loq/login
instead of /bq/login
. It logins, sends, and receives perfectly on my machine (I was getting 400s as well before). When I find some time this weekend I will work on completely removing the dependency on pysnap
and implementing the new /loq
endpoints.
that fix worked for me, thanks so much!
This still doesn't work - fetching from the updates
endpoint fails.
This seems to be working for me. Great job, really appreciate your efforts. Thanks!
Great job, it work for me ! Thank's
I just have an error on the /friend :
[2015-03-04 09:00:00,631] "POST /bq/updates HTTP/1.1" 200 None
[2015-03-04 09:00:00,678] [StorifierBot-5659] User MyUser added me
[2015-03-04 09:00:00,678] Starting new HTTPS connection (1): feelinsonice-hrd.appspot.com
[2015-03-04 09:00:01,117] "POST /bq/friend HTTP/1.1" 200 None
Traceback (most recent call last):
File "C:\Users\root\Desktop\FeedMySnap\FMS-PARIS.py", line 19, in <module>
bot.listen()
File "C:\Users\root\Desktop\FeedMySnap\snapchat_bots\bot.py", line 78, in listen
self.on_friend_add(friend)
File "C:\Users\root\Desktop\FeedMySnap\FMS-PARIS.py", line 12, in on_friend_add
self.send_snap(friend, Snap.from_file("resources/auto_welcome.png"))
NameError: global name 'Snap' is not defined
You need to import Snap from snapchat_bots as well.
— Sent from Mailbox
On Wed, Mar 4, 2015 at 4:03 AM, Romain notifications@github.com wrote:
Great job, it work for me ! Thank's I just have an error on the /friend : [2015-03-04 09:00:00,631] "POST /bq/updates HTTP/1.1" 200 None [2015-03-04 09:00:00,678] [StorifierBot-5659] User MyUser added me [2015-03-04 09:00:00,678] Starting new HTTPS connection (1): feelinsonice-hrd.appspot.com [2015-03-04 09:00:01,117] "POST /bq/friend HTTP/1.1" 200 None
Traceback (most recent call last): File "C:\Users\root\Desktop\FeedMySnap\FMS-PARIS.py", line 19, in <module> bot.listen() File "C:\Users\root\Desktop\FeedMySnap\snapchat_bots\bot.py", line 78, in listen self.on_friend_add(friend) File "C:\Users\root\Desktop\FeedMySnap\FMS-PARIS.py", line 12, in on_friend_add self.send_snap(friend, Snap.from_file("resources/auto_welcome.png")) NameError: global name 'Snap' is not defined
Reply to this email directly or view it on GitHub: https://github.com/agermanidis/SnapchatBot/issues/26#issuecomment-77119840
Working great, @agermanidis.
Very quick update, I'm glad.
@Rob--, what kind of error code are you getting?
@agermanidis - not an error code, the way you handle the content returned in the request is invalid. I get a few updates_responses
messages, and then it's followed by a few No JSON object could be decoded
.
I haven't got the time to look through your library right now and find the errors because I'm going to try another solution.
Edit: never mind, it does work (both locally and on a server) - I'm currently expanding on your library to implement the latest endpoints.
It's working for me. Awesome !
It says you're unauthorised - I'm not too sure if I'm correct but I believe this means that your auth_token
might be invalid. This could have to do with the owner's new implementation of loq
which doesn't look fully finished.
Since the 400 error issue seems to have been resolved, I'm closing this. Please move the discussion of other errors to relevant (new or existing) issues. Thanks!
@Rob-- Do you have a solution for your error ?
I get a few
updates_responses
messages, and then it's followed by a fewNo JSON object could be decoded.
@ricoxor - no, I fixed it by updating the get updates methods to use the latest endpoint.
Can i have a contact with you @Rob-- ? Skype ? Mail :) Thank's
@ricoxor yeah sure, leave your Skype or something and I'll contact you.
@Rob-- Hi Rob, I tried using /loq/login
instead of the old /bq/login
endpoint, but it's still giving me 400 BAD_REQUEST
. Any idea on why this could happen?
Hi, I was running a SnapChatBot fine yesterday, but this morning I got this error.
HTTPError: 400 Client Error: Bad Request
Running Python 2.7 Mac OSX Yosemite
Its it something wrong with the host feelinsonice-hrd.appspot.com or is it my coding mistake? Anyone else get the same error?