-
Notifications
You must be signed in to change notification settings - Fork 1
/
fetch.php
89 lines (81 loc) · 2.45 KB
/
fetch.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
<html>
<head>
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<?php
include "simplehtmldom/simple_html_dom.php";
require __DIR__ . '/vendor/autoload.php';
$client = new \Google_Client();
$client->setApplicationName('Mynavi');
$client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
$client->setAuthConfig(__DIR__.'/credentials.json');
$client->setAccessType('offline');
$service = new Google_Service_Sheets($client);
$spreadsheetId = "1aD-BoZIEsx6oi6A8AI38t3oAqAwShcynmQoGQd1LxnU";
$range = "Sheet1!A2:B";
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();
$num_row = 0;
set_time_limit(0);
if (empty($values)) {
} else {
$num_row = sizeOf($values);
}
$value = [];
for($i =0 ; $i<19; $i++){
$data = $values[$i];
$url = "https://wax.eosrio.io/v2/state/get_account?account=".$data[1];
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $url);
sleep(1);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
sleep(1);
// $output contains the output string
$output = json_decode(curl_exec($ch));
var_dump(($output->tokens)[0]->amount);
$wax = 0;
$tlm = 0;
if(isset(($output->tokens)[1]->amount)){
for($c = 0; $c< sizeof($output->tokens);$c++){
if(($output->tokens)[$c]->symbol == 'WAX'){
$wax = ($output->tokens)[$c]->amount;
}
if(($output->tokens)[$c]->symbol == 'TLM'){
$tlm = ($output->tokens)[$c]->amount;
}
}
}
$value[$i] = [
$wax ,
$tlm,
isset($output->account->cpu_limit->available) ? $output->account->cpu_limit->available : '',
isset($output->account->cpu_limit->max) ? $output->account->cpu_limit->max : '',
isset($output->account->cpu_limit->used) ? ceil(($output->account->cpu_limit->used)*100/$output->account->cpu_limit->max) : '',
isset((($output->actions)[0])->timestamp) ? (($output->actions)[0])->timestamp : ''
];
curl_close($ch);
sleep(1);
}
var_dump($value);
$range2 = 'Sheet1!C2:H';
$body = new Google_Service_Sheets_ValueRange(
[
'values' => $value
]
);
$params = [
'valueInputOption' => 'RAW'
];
$result = $service->spreadsheets_values->update(
$spreadsheetId,
$range2,
$body,
$params
);
?>
</body>
</html>