-
Notifications
You must be signed in to change notification settings - Fork 4
/
load_feed_data.php
32 lines (23 loc) · 1012 Bytes
/
load_feed_data.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
<?php
chdir("/var/www/emoncms");
require "Lib/load_emoncms.php";
require "/opt/emoncms/modules/sync/lib/phpfina.php";
require_once "Modules/feed/feed_model.php";
$feed_class = new Feed($mysqli,$redis,$settings["feed"]);
$local_datadir = "/home/trystan/Desktop/Drive/energylocal/";
$remote_server = "https://dashboard.energylocal.org.uk";
// get all users
$result = $mysqli->query("SELECT * FROM users");
while ($row = $result->fetch_object()) {
$userid = $row->id;
print $userid." ".$row->username."\n";
$feeds = $feed_class->get_user_feeds($userid,1);
foreach ($feeds as $feed) {
$feedid = (int) $feed['id'];
$meta = json_decode(file_get_contents("https://dashboard.energylocal.org.uk/feed/getmeta.json?id=$feedid&apikey=".$row->apikey_read));
$interval = $meta->interval;
if ($interval==1800) {
phpfina_download($local_datadir,$feedid,$remote_server,$feedid,$row->apikey_write);
}
}
}