Skip to content

Commit

Permalink
Changed apikeyhandler
Browse files Browse the repository at this point in the history
  • Loading branch information
christoffer-bolin committed Dec 4, 2020
1 parent e85e4ea commit fa12a2f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Models/WeatherForecast.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ class WeatherForecast

public function __construct()
{
global $di;
$this->oneWeek = [];
$this->weather = [];
}


public function fetchApiKey()
{
$config = $di->get("configuration")->load("weatherapi.php");
$access_key = $this->config["config"]["weatherKeyHolder"]["weatherKey"];

$access_key = require ANAX_INSTALL_PATH . "/config/weatherapi.php";
$access_key = $access_key["weatherKeyHolder"]["weatherKey"];
return $access_key;
}

Expand All @@ -29,7 +27,7 @@ public function checkWeather($lat, $lon)

$access_key = $this->fetchApiKey();

$ch = curl_init('https://api.openweathermap.org/data/2.5/onecall?lat='.$lat.'&lon='.$lon.'&exclude='.$exclude.'&units=metric&lang=sv&appid='.$this->access_key.'');
$ch = curl_init('https://api.openweathermap.org/data/2.5/onecall?lat='.$lat.'&lon='.$lon.'&exclude='.$exclude.'&units=metric&lang=sv&appid='.$access_key.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Store the data:
Expand Down

0 comments on commit fa12a2f

Please sign in to comment.