1 | <?php |
||
7 | class Auth extends BaseApi |
||
8 | { |
||
9 | /** |
||
10 | * Betfair API endpoint for authentication requests |
||
11 | */ |
||
12 | const ENDPOINT = 'https://identitysso.betfair.com/api/'; |
||
13 | |||
14 | /** |
||
15 | * 4 hours, expressed in seconds |
||
16 | */ |
||
17 | const SESSION_LENGTH = 4 * 60 * 60; |
||
18 | |||
19 | /** |
||
20 | * Application key, provided by Betfair on registration |
||
21 | */ |
||
22 | public static $appKey = null; |
||
23 | |||
24 | /** |
||
25 | * Session token, provided by Betfair at login |
||
26 | */ |
||
27 | public static $sessionToken = null; |
||
28 | |||
29 | /** |
||
30 | * Time of last login, expressed in seconds since the Unix Epoch |
||
31 | */ |
||
32 | public static $lastLogin = null; |
||
33 | |||
34 | /** |
||
35 | * Wrapper method for other methods to initiate and manage a Betfair session |
||
36 | * |
||
37 | * @param string $appKey |
||
38 | * @param string $username |
||
39 | * @param string $password |
||
40 | */ |
||
41 | public function init($appKey, $username, $password) |
||
50 | |||
51 | /** |
||
52 | * Accept app key and session token and extend session |
||
53 | * |
||
54 | * @param string $appKey |
||
55 | * @param string $sessionToken |
||
56 | */ |
||
57 | public function persist($appKey, $sessionToken) |
||
63 | |||
64 | /** |
||
65 | * Method to directly execute Betfair login request. |
||
66 | * For use only when the init() method isn't appropriate |
||
67 | * |
||
68 | * @param string $appKey |
||
69 | * @param string $username |
||
70 | * @param string $password |
||
71 | */ |
||
72 | public function login($appKey, $username, $password) |
||
85 | |||
86 | /** |
||
87 | * Execute Betfair API call to extend the current session |
||
88 | */ |
||
89 | public function keepAlive() |
||
98 | |||
99 | /** |
||
100 | * Execute Betfair API call to logout from their system. |
||
101 | * Clear all local references to the session. |
||
102 | */ |
||
103 | public function logout() |
||
114 | |||
115 | /** |
||
116 | * Calculate and provide the time remaining until the current session token expires |
||
117 | */ |
||
118 | public function sessionRemaining() |
||
122 | } |
||
123 |