mirror of
https://github.com/seigler/neat-charts
synced 2025-07-26 17:06:09 +00:00
21 lines
723 B
PHP
21 lines
723 B
PHP
<?php
|
|
|
|
class Util {
|
|
public static function getJson($url) {
|
|
if (empty($url)) {
|
|
trigger_error('Missing or empty JSON url');
|
|
}
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
|
# curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
|
# curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
|
# curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/VeriSignClass3PublicPrimaryCertificationAuthority-G5.pem");
|
|
|
|
$result = curl_exec($ch);
|
|
$result = json_decode($result) or trigger_error('Couldn\'t parse JSON');
|
|
return $result;
|
|
}
|
|
}
|