-
Notifications
You must be signed in to change notification settings - Fork 0
/
poller.php
executable file
·112 lines (91 loc) · 2.39 KB
/
poller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
require('grooveshark.php');
require('database.php');
if (isset($_GET['debug']))
{
ini_set('display_errors','On');
error_reporting(E_ALL);
$debug = true;
}
else
{
$debug = false;
}
/*
1 - token
2 - sessionID
2 - key
3 - "The rest"
A - Check session data cache integrety
B - Update session data cache if necessary
C - Get token for this session and cache
D - Foreach broadcast, query with cache
A - Get cached session data
B - Attempt to get token
B1 - If failed, refresh session data
B2 - If success, cache token
C - Foreach broadcast...
A - get broadcaststats
AF - renew token
AFF - renew session
*/
/*
DataBaseConnection db = ...
Grooveshark $grooveShark = ...
$grooveShark->SessionData = db->GetSessionData();
if ($grooveShark->SessionData == null)
{
// No session data has been cached yet, get it.
$grooveShark->SessionData = AccquireSessionData();
}
if ($grooveShark->SessionData != null)
{
$grooveShark->Token = $grooveShark->AccquireToken();
if ($grooveShark->Token == null)
{
$grooveShark->SessionData = AccquireSessionData();
$grooveShark->Token = $grooveShark->AccquireToken();
}
if ($grooveShark->Token == null)
{
// Log message, failed to get token a second time.
}
else
{
$users = db->GetEnabledBroadcasts();
foreach ($username in $users)
{
try
{
gsData = $grooveShark->GetData();
if (gsData != null)
{
// Parse and write to db
}
else
{
throw new Exception("Could not get data for user.");
}
}
catch ($exception)
{
// Log message for this user
}
}
}
}
function AccquireSessionData()
{
sessionData = Grooveshark->QuerySessionData();
if (sessionData == null)
{
// Trigger some failure
// email
}
else
{
db->SaveSessionData(sessionData);
}
return sessionData;
}
*/