Skip to content

Commit 3c65ce4

Browse files
committed
Added auth token option to constructor
1 parent ba5767b commit 3c65ce4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/snapchat.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ class Snapchat {
3232

3333

3434
/**
35-
* Sets up some initial variables.
35+
* Sets up some initial variables. If a username and password are passed in,
36+
* we attempt to log in. If a username and auth token are passed in, we'll
37+
* bypass the login process and use those values.
3638
*/
37-
public function __construct($username = NULL, $password = NULL) {
39+
public function __construct($username = NULL, $password = NULL, $auth_token = NULL) {
3840
$this->auth_token = FALSE;
3941
$this->username = FALSE;
4042

41-
if (!empty($username)) $this->login($username, $password);
43+
if (!empty($username)) {
44+
if (!empty($password)) {
45+
$this->login($username, $password);
46+
}
47+
elseif (!empty($auth_token)) {
48+
$this->auth_token = $auth_token;
49+
$this->username = $username;
50+
}
51+
}
4252
}
4353

4454

0 commit comments

Comments
 (0)