скорректирована структура
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
const STORAGE_DIR = __DIR__ . '/../data';
|
const STORAGE_DIR = __DIR__ . '/../data';
|
||||||
const STORAGE_RUN_DIR = __DIR__ . '/../run';
|
const STORAGE_RUN_DIR = __DIR__ . '/../run';
|
||||||
|
|
||||||
require_once __DIR__ . '/lib/YandexIoT.php';
|
|
||||||
require_once __DIR__ . '/lib/Prometheus.php';
|
|
||||||
require_once __DIR__ . '/lib/Narodmon.php';
|
|
||||||
|
|
||||||
/** Идентификатор устройства народного мониторинга */
|
/** Идентификатор устройства народного мониторинга */
|
||||||
const NARODMON_DEVICE_ID = 'AE-71-70-50-00-01';
|
const NARODMON_DEVICE_ID = 'AE-71-70-50-00-01';
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Rsgrinko\\IotApi\\": "inc/lib/"
|
"Rsgrinko\\IotApi\\": "lib/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Rsgrinko\IotApi;
|
||||||
|
|
||||||
class Narodmon
|
class Narodmon
|
||||||
{
|
{
|
||||||
private const API_ENDPOINT = 'http://narodmon.ru/post';
|
private const API_ENDPOINT = 'http://narodmon.ru/post';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace Rsgrinko\IotApi;
|
||||||
class Prometheus
|
class Prometheus
|
||||||
{
|
{
|
||||||
private array $data = [];
|
private array $data = [];
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Rsgrinko\IotApi;
|
||||||
|
|
||||||
class YandexIoT
|
class YandexIoT
|
||||||
{
|
{
|
||||||
private string $clientId;
|
private string $clientId;
|
||||||
@@ -28,7 +30,7 @@ class YandexIoT
|
|||||||
throw new RuntimeException('Файл для инициализации не найден');
|
throw new RuntimeException('Файл для инициализации не найден');
|
||||||
}
|
}
|
||||||
$data = json_decode(file_get_contents($file), true, 512, JSON_THROW_ON_ERROR);
|
$data = json_decode(file_get_contents($file), true, 512, JSON_THROW_ON_ERROR);
|
||||||
$this->accessToken = $data['access_token'] ?? null;
|
$this->accessToken = $data['access_token'] ?? null;
|
||||||
$this->refreshToken = $data['access_token'] ?? null;
|
$this->refreshToken = $data['access_token'] ?? null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -43,8 +45,12 @@ class YandexIoT
|
|||||||
* @return array
|
* @return array
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public static function sendRequest(string $url, array $headers = [], ?array $data = null, ?string $method = null): array
|
public static function sendRequest(
|
||||||
{
|
string $url,
|
||||||
|
array $headers = [],
|
||||||
|
?array $data = null,
|
||||||
|
?string $method = null
|
||||||
|
): array {
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Rsgrinko\IotApi\Narodmon;
|
||||||
|
use Rsgrinko\IotApi\Prometheus;
|
||||||
|
use Rsgrinko\IotApi\YandexIoT;
|
||||||
|
|
||||||
require_once __DIR__ . '/inc/bootstrap.php';
|
require_once __DIR__ . '/inc/bootstrap.php';
|
||||||
|
|
||||||
header('Content-Type: text/plain');
|
header('Content-Type: text/plain');
|
||||||
$prometheusObject = new Prometheus();
|
$prometheusObject = new Prometheus();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user