<?php
require_once dirname(__DIR__).'/config.php';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array("Content-Type: application/json"),
CURLOPT_CUSTOMREQUEST => "POST"));
function api_call($path, $data)
{
global $curl;
global $config;
$data['authtoken'] = $config['api_token'];
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_URL, $config['api_url'].$path);
$response = curl_exec($curl);
$err = curl_error($curl);
$ret = @json_decode($response, true);
if (!isset($ret['status']) || $ret['status'] == 'error') {
echo $response;
}
return $ret;
}