forked from friendica/friendica-addons
Replace call for Logger with DI::logger() in geocoordinates addon
This commit is contained in:
parent
1db552ead9
commit
e7755584cb
1 changed files with 4 additions and 5 deletions
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -51,25 +50,25 @@ function geocoordinates_resolve_item(array &$item)
|
||||||
$s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language);
|
$s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language);
|
||||||
|
|
||||||
if (!$s) {
|
if (!$s) {
|
||||||
Logger::info('API could not be queried');
|
DI::logger()->info('API could not be queried');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = json_decode($s);
|
$data = json_decode($s);
|
||||||
|
|
||||||
if ($data->status->code != '200') {
|
if ($data->status->code != '200') {
|
||||||
Logger::info('API returned error ' . $data->status->code . ' ' . $data->status->message);
|
DI::logger()->info('API returned error ' . $data->status->code . ' ' . $data->status->message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($data->total_results == 0) || (count($data->results) == 0)) {
|
if (($data->total_results == 0) || (count($data->results) == 0)) {
|
||||||
Logger::info('No results found for coordinates ' . $item['coord']);
|
DI::logger()->info('No results found for coordinates ' . $item['coord']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['location'] = $data->results[0]->formatted;
|
$item['location'] = $data->results[0]->formatted;
|
||||||
|
|
||||||
Logger::info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
|
DI::logger()->info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
|
||||||
|
|
||||||
if ($item['location'] != '') {
|
if ($item['location'] != '') {
|
||||||
DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $item['location']);
|
DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $item['location']);
|
||||||
|
|
Loading…
Reference in a new issue