@@ -109,6 +109,50 @@ $snapchat->logout();
109
109
?>
110
110
```
111
111
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
+ ```
112
156
113
157
Documentation
114
158
------------
0 commit comments