-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelstra.php
57 lines (51 loc) · 1.84 KB
/
telstra.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
<?php
// Export Telstra Group Usage Data to CSV
// By Tom Kavanagh https://github.com/tkav/telstra-data-usage
Class Telstra {
function login($Username, $Password) {
$url = 'https://telstra.com/siteminderagent/SMLogin/preLogin.do';
$ch = curl_init();
$fields = array(
'user' => $Username,
'password' => $Password,
'TARGET' => '',
'smsauthreason' => 0,
'error_target' => '',
'final_target' => '',
'postpreservationdata' => '',
'generallogondata' => ''
);
$data = http_build_query($fields);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'session.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'session.txt');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 40);
$buffer = curl_exec($ch);
curl_close($ch);
return $buffer;
}
function getGroupUsage($csv="telstra_usage.csv",$detailed=0) {
$url = 'https://es.telstra.com/MobileDataUsageMeter/csvdownload.do';
if ($detailed == 1) {
$url = $url.'?typeOfDownload=on';
}
$ch = curl_init();
$fp = fopen($csv, "w");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'session.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'session.txt');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 40);
$buffer = curl_exec($ch);
fclose($fp);
curl_close($ch);
return $buffer;
}
}
?>