Skip to content

Commit 2589843

Browse files
committed
Updated documentation with an example on how to store the auth key between requests
1 parent d39f353 commit 2589843

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,50 @@ $snapchat->logout();
109109
?>
110110
```
111111

112+
How to stop getting blocked by Snapchat
113+
------------
114+
This example will show you how to log into an account and store the auth key between sessions.
115+
This is just an example and should not be deployed to production (you need to keep that auth key secret!)
116+
117+
```php
118+
//Set your own login info here.
119+
$username = 'YourSnapChatUsernameHere';
120+
$password = 'YuorSnapChatPasswordHere';
121+
122+
$snapchat = null;
123+
/*
124+
Check if the auth file exists.
125+
Remember the auth token is different for each user you access
126+
You should probably also store this somewhere safe!!
127+
Outside your webroot at least.....
128+
*/
129+
$authFilePath = __DIR__.'/auth_token.txt';
130+
if(file_exists($authFilePath))
131+
{
132+
//Username, password as null, and grab the exisiting token from disk.
133+
$snapchat = new Snapchat($username, null, file_get_contents($authFilePath));
134+
echo 'We logged in with an existing auth token! :D<br />', PHP_EOL;
135+
}
136+
else
137+
{
138+
//Log in the old fashioned way.
139+
$snapchat = new Snapchat($username, $password);
140+
echo 'We logged in the old fashioned way! :(<br />', PHP_EOL;
141+
}
142+
143+
//Check if we failed to log in succesfully
144+
if(!$snapchat->isLoggedIn())
145+
{
146+
die("Could not log into snapchat!");
147+
}
148+
//Store the auth token on disk so we don't have to log in again and again.
149+
file_put_contents($authFilePath, $snapchat->getAuthToken());
150+
151+
// Get your information.
152+
$snaps = $snapchat->getUpdates();
153+
//var_dump($snaps); //If you want to see the raw data
154+
echo 'Your birthday is: ', $snaps->birthday, ' <br />', PHP_EOL;
155+
```
112156

113157
Documentation
114158
------------

0 commit comments

Comments
 (0)