JorgenPhi / php-snapchat

A PHP library for the Snapchat API - With Commit History
MIT License
259 stars 73 forks source link

Fail to login. #83

Open Scape373 opened 9 years ago

Scape373 commented 9 years ago

No matter what it wont log in.... Im trying to get it to login and send a snap, but cant even get it to log in first.

Where am i supposed to find my auth token also?

just keep getting this:

We logged in the old fashioned way! :( Could not log into snapchat!

<?php require_once("./src/snapchat.php");

//Set your own login info here. $username = 'my username'; $password = 'passwordy stuffs';

$snapchat = null; / Check if the auth file exists. Remember the auth token is different for each user you access You should probably also store this somewhere safe!! Outside your webroot at least..... / $authFilePath = DIR.'/auth_token.txt'; if(file_exists($authFilePath)) { //Username, password as null, and grab the exisiting token from disk. $snapchat = new Snapchat($username, null, file_get_contents($authFilePath)); echo 'We logged in with an existing auth token! :D
', PHP_EOL; } else { //Log in the old fashioned way. $snapchat = new Snapchat($username, $password); echo 'We logged in the old fashioned way! :(
', PHP_EOL; }

//Check if we failed to log in succesfully if(!$snapchat->isLoggedIn()) { die("Could not log into snapchat!");

} //Store the auth token on disk so we don't have to log in again and again. file_put_contents($authFilePath, $snapchat->getAuthToken());

// Get your information. $snaps = $snapchat->getUpdates(); var_dump($snaps); //If you want to see the raw data echo 'Your birthday is: ', $snaps->birthday, '
', PHP_EOL;

?>

Dubz commented 9 years ago

I'm getting the same issue here as well. My iPad seems to work fine, I can login and see snaps/stories with no issue.

EDIT I also created a new account just to make sure it wasn't account related or anything and got the same results. I can still send snaps as well so the issue is with the source of the script.

realmuster commented 9 years ago

Hello together, I just had to register to GitHub, wasn't using it until today. But I am currently using the php-snapchat Library for my own small client. I have the same issue described here for about two or three days. Not possible to login into Snapchat anymore. I will try to investigate for the problem, but if anyone has found the problem yet, please let me know.

EDIT: Well, the return of the Snapchat API is the following:

<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>400 BAD_REQUEST</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: BAD_REQUEST</h1>
</body></html>

and with the curl_getinfo() function I can't get any more information. Any Ideas?

Snowlav commented 9 years ago

@realmuster looks like snapchat blocked the network you are trying to connect from.

Dubz commented 9 years ago

@Snowlav I've tested this on multiple networks/accounts and I get blocked out too for no reason. I can also login to my account from my iPad with no issues so the account and network aren't the issue.

Snowlav commented 9 years ago

@Dubz what is the error you are getting? If you accounts aren't locked and your network is not blocked, it must be the code.

Dubz commented 9 years ago

@Snowlav That's what I'm saying. I don't know what it's saying, it just fails. I haven't added any debug code of any type to the code to print anything out.

I did an export of the snapchat object after logging in and it has the username and auth_token both false.

EDIT I added the debug and got a 400 bad request as well. Any idea on a fix? I've tried multiple accounts and networks. My iPad works just fine on the same network (with the same account).

realmuster commented 9 years ago

Hey together. I found my problem. It was not the problem that the IP was blocked. It was the Problem that my account was blocked. I had to visit the url snapchat.com/locked to unlock my account. And if you visit this url you can read a text about using third-party applications.

I think someone needs to investigate the actual data that is sending to snapchat. We need to know what snapchat gets to know so we can send it as well and they do not see where the request exactly comes from.

Dubz commented 9 years ago

Tried the above just now, nothing. I'm still being blocked form the script only.

Snowlav commented 9 years ago

This is strange, you sure it's a 400 bad request and not a 401? are you running your script from a local IP or from a webhost? @Dubz

Dubz commented 9 years ago

Logging in... '< html>< head> < meta http-equiv="content-type" content="text/html;charset=utf-8"> < title>400 BAD_REQUEST< /title> < /head> < body text=#000000 bgcolor=#ffffff> < h1>Error: BAD_REQUEST< /h1> < /body>< /html> ' failed!

Straight from the post function. I added the following code between lines 316 and 317 in snapchat_agent.php: var_export($result);

The "Logging in..." and "failed!" are from the console in the code I created with this source. I've tried it with multiple accounts and IP's as well as the same IP/account combination that my iPad worked with without errors.

I had to add a space after each < in the html to keep it from rendering to HTML in the comments.

Snowlav commented 9 years ago

@Dubz refer to my previous question, are you running this from local server (with the same IP as your ipad etc) or from a remote server / webhost? (with an other IP)

If it's the latter, then this all makes sense, the IP your webhost is using is banned. Try a proxy.

Voiceeeeee commented 9 years ago

Same thing here, unable to login to ANY accounts, while I can using my iPod, I'm locally hosted. Edit: Fixed it by using this pull. https://github.com/JorgenPhi/php-snapchat/pull/80

Dubz commented 9 years ago

Thanks for the tip @Voiceeeeee, that seemed to work for me. Guess these have to stay up to date.

j0rd commented 9 years ago

80 worked for me.

Dubz commented 9 years ago

I just got an email from snapchat warning me not to use third party applications. I run this script on localhost so there must still be something in the code that tips them off, or they've been checking this repo now. Seems like this needs some more randomization of some type.

Voiceeeeee commented 9 years ago

My account got locked for "repeatedly using third-part applications", I'm also on localhost, not sure why this is happening. But it's easy to get it unlocked here, http://snapchat.com/locked, but I don't know if it's a one time thing.

Dubz commented 9 years ago

@Voiceeeeee I did that, it didn't fix my initial problem, probably because it wasn't locked at all. Issue #80 did fix it, but it seems like it's not going to last long.

Voiceeeeee commented 9 years ago

Yea, there probably is something other than #80, but I have no idea what it is, everything seems to be right.

Snowlav commented 9 years ago

http://puu.sh/eO5nV/6b4e58fb0d.png "If you believe you received the notification in error, it may be because you are using an old version of Snapchat. Please make sure you have the most recent version of the app downloaded."

Makes me believe it's a combination of the right headers and endpoints. Since the newer version of snapchat uses new endpoints and the current php lib does not.

Using a header / user-agent with the latest version but old endpoints is an easy giveaway.

While managing a single account, new endpoints, new headers I have not yet been locked. While managing multiple accounts, so far only the network has been blocked for approx 48 hours every time.