src/includes/classes/Core/Utils/Twitter.php
public function getJson(string $path, array $args = []): \StdClass
    {
        $default_args = $this->default_credentials + [
            'request'       => [],
            'cache'         => true,
            'cache_max_age' => strtotime('-15 minutes'),
        ];
        $args += $default_args; // Merge defaults.

        $time = time(); // Current time.

        $args['request']       = (array) ($args['request'] ?: []);
        $args['cache']         = (bool) $args['cache']; // Enable cache?
        $args['cache_max_age'] = max(0, min($time, (int) $args['cache_max_age']));

        $remote_hash = $this->remoteHash($args);
        $request_str = serialize($args['request']);

        $cache_sha1            = sha1($remote_hash.':'.$path.':'.$request_str);
        $cache_dir_permissions = $this->App->Config->©fs_permissions['©transient_dirs'];
        $cache_dir             = $this->cache_dir.'/'.$this->c::sha1ModShardId($cache_sha1, true);
        $cache_file            = $cache_dir.'/'.$cache_sha1; // Hash location.

        if ($args['cache'] && is_file($cache_file) && filemtime($cache_file) >= $args['cache_max_age']) {
            return $response_object = json_decode(file_get_contents($cache_file));
        }
        $remote        = $this->getRemote($args);
        $response      = $remote->get($path, $args['request']);
        $response_code = (int) $remote->getLastHttpCode();

        $response_object = (object) [
            'success' => $response_code && $response_code < 400,
            'data'    => $response,
            'remote'  => $remote,
        ];
        if ($args['cache']) {
            if (!is_dir($cache_dir)) {
                mkdir($cache_dir, $cache_dir_permissions, true);
            }
            file_put_contents($cache_file, json_encode($response_object));
        }
        return $response_object;
    }
public function getJson(string $path, array $args = []): \StdClass
    {
        $default_args = $this->default_credentials + [
            'request'       => [],
            'cache'         => true,
            'cache_max_age' => strtotime('-15 minutes'),
        ];
        $args += $default_args; // Merge defaults.

        $time = time(); // Current time.

        $args['request']       = (array) ($args['request'] ?: []);
        $args['cache']         = (bool) $args['cache']; // Enable cache?
        $args['cache_max_age'] = max(0, min($time, (int) $args['cache_max_age']));

        $remote_hash = $this->remoteHash($args);
        $request_str = serialize($args['request']);

        $cache_sha1            = sha1($remote_hash.':'.$path.':'.$request_str);
        $cache_dir_permissions = $this->App->Config->©fs_permissions['©transient_dirs'];
        $cache_dir             = $this->cache_dir.'/'.$this->c::sha1ModShardId($cache_sha1, true);
        $cache_file            = $cache_dir.'/'.$cache_sha1; // Hash location.

        if ($args['cache'] && is_file($cache_file) && filemtime($cache_file) >= $args['cache_max_age']) {
            return $response_object = json_decode(file_get_contents($cache_file));
        }
        $remote        = $this->getRemote($args);
        $response      = $remote->get($path, $args['request']);
        $response_code = (int) $remote->getLastHttpCode();

        $response_object = (object) [
            'success' => $response_code && $response_code < 400,
            'data'    => $response,
            'remote'  => $remote,
        ];
        if ($args['cache']) {
            if (!is_dir($cache_dir)) {
                mkdir($cache_dir, $cache_dir_permissions, true);
            }
            file_put_contents($cache_file, json_encode($response_object));
        }
        return $response_object;
    }
GET JSON response.

@since 17xxxx Twitter utils.

@param string $url  API path.
@param array  $args Additional args.

@return \StdClass Including a `success` property.