38 行
908 B
PHP
38 行
908 B
PHP
<?php
|
|
require_once('../config.php');
|
|
|
|
function lolicurl ($url, $param='', $method='get', $contenttype='json') {
|
|
set_time_limit(0);
|
|
$header = ['Content-Type: application/'.$contenttype, 'Host: '.str_replace('https://', '', API_URI)];
|
|
|
|
if (!is_null(API_AUTH)) {
|
|
$header[] = 'Authorization: Bearer '.API_AUTH;
|
|
}
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, API_URI.$url);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
if ($method == 'post') {
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
if ($param != '') curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
|
|
}
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
$get = curl_exec($ch);
|
|
$err = curl_error($ch);
|
|
curl_close($ch);
|
|
|
|
if (!$get) {
|
|
return $err;
|
|
}
|
|
|
|
$get = json_decode($get);
|
|
|
|
if (isset($get->status) && $get->status == 404) {
|
|
return [];
|
|
}
|
|
|
|
return $get;
|
|
}
|
|
?>
|