diff --git a/SpeedtestTracker/SpeedtestTracker.php b/SpeedtestTracker/SpeedtestTracker.php index b7bddebd43..4f7fc55184 100644 --- a/SpeedtestTracker/SpeedtestTracker.php +++ b/SpeedtestTracker/SpeedtestTracker.php @@ -11,6 +11,20 @@ class SpeedtestTracker extends \App\SupportedApps implements \App\EnhancedApps //protected $login_first = true; // Uncomment if api requests need to be authed first //protected $method = 'POST'; // Uncomment if requests to the API should be set by POST + public function getRequestAttrs() + { + $api_token = $this->config->apikey; + + $attrs = [ + "headers" => [ + "Accept" => "application/json", + "Authorization" => "Bearer " . $api_token, + ], + ]; + + return $attrs; + } + public function __construct() { //$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set @@ -18,14 +32,16 @@ public function __construct() public function test() { - $test = parent::appTest($this->url("api/speedtest/latest/")); + $attrs = $this->getRequestAttrs(); + $test = parent::appTest($this->url("api/v1/results/latest/"), $attrs); echo $test->status; } public function livestats() { $status = "inactive"; - $res = parent::execute($this->url("api/speedtest/latest/")); + $attrs = $this->getRequestAttrs(); + $res = parent::execute($this->url("api/v1/results/latest/"), $attrs); $details = json_decode($res->getBody()); $data = []; @@ -78,7 +94,7 @@ private static function formatUsingStat($stat, $number) switch ($stat) { case "download": case "upload": - return number_format($number) . "Mbit/s"; + return number_format($number * 8 / 1000000) . "Mbit/s"; case "ping": return number_format($number) . "ms"; case "created_at": diff --git a/SpeedtestTracker/app.json b/SpeedtestTracker/app.json index 6d1755f057..4b0e2e878d 100644 --- a/SpeedtestTracker/app.json +++ b/SpeedtestTracker/app.json @@ -1,8 +1,8 @@ { "appid": "c106a4464d1b08d0e35edb92ddfabae6f9dc765f", "name": "Speedtest Tracker", - "website": "https://github.com/henrywhitaker3/Speedtest-Tracker", - "license": "GNU General Public License v3.0 only", + "website": "https://github.com/alexjustesen/speedtest-tracker", + "license": "MIT License", "description": "This program runs a speedtest check every hour and graphs the results. The back-end is written in Laravel and the front-end uses React. It uses the Ookla's speedtest cli package to get the data and uses Chart.js to plot the results.", "enhanced": true, "tile_background": "dark", diff --git a/SpeedtestTracker/config.blade.php b/SpeedtestTracker/config.blade.php index e689fe0f28..c391e45203 100755 --- a/SpeedtestTracker/config.blade.php +++ b/SpeedtestTracker/config.blade.php @@ -1,8 +1,8 @@