Файл: install/system/classes/Api.php
Строк: 24
<?php
class Api
{
protected
$url_api = 'http://netscms.ru/api/',
$init;
public function __construct()
{
$this->init = curl_init();
}
public function query($method, $param)
{
$main = [
'method' => $method
];
$result = $this->curl($this->url_api, http_build_query(array_merge($main, $param)));
$array = json_decode($result, true);
if (isset($array['response']))
{
return $array['response'];
}
else
{
return $array['error'];
}
}
function curl($url, $post)
{
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post
];
curl_setopt_array($this->init, $options);
return curl_exec($this->init);
}
}