Ejemplo n.º 1
0
 function getStations()
 {
     $cache = new Gilbitron\Util\SimpleCache();
     $cache->cache_path = 'cache/';
     $cache->cache_time = 86400;
     //cache for one day
     if ($data = $cache->get_cache('all_stations')) {
         $data = json_decode($data);
     } else {
         $stations = $this->wmata->get('Rail.svc/json/jStations', ['query' => ['api_key' => $this->config->wmata_api_key]]);
         $stations = $stations->getBody();
         $cache->set_cache('all_stations', $stations);
         $data = json_decode($stations);
     }
     return $data->Stations;
 }
Ejemplo n.º 2
0
<?php

require 'lib/SimpleCache.php';
require 'settings.php';
header('Content-Type: application/json');
$cache = new Gilbitron\Util\SimpleCache();
$cache->cache_time = 120;
$query = $_GET['query'];
$endpoint = $_GET['endpoint'];
$key = $endpoint . $query;
if ($data = $cache->get_cache($key)) {
    header('Age: ' . $cache->get_cache_age($key));
} else {
    header('Age: 0');
    $url = 'http://realtime.mbta.com/developer/api/v2/' . $endpoint . '?' . $query . '&api_key=' . $API_KEY;
    $data = $cache->do_curl($url);
    $cache->set_cache($key, $data);
}
print $data;
Ejemplo n.º 3
0
<?php

/**
 * Gravatar Proxy
 * The proxy itself
 *
 * PHP version 5.4
 *
 * @category Plugin
 * @package  Gravatar_Proxy
 * @author   Pierre Rudloff <*****@*****.**>
 * @license  GPL http://www.gnu.org/licenses/gpl.html
 * @link     https://rudloff.pro/
 */
require_once __DIR__ . '/vendor/autoload.php';
$cache = new Gilbitron\Util\SimpleCache();
$cache->cache_path = __DIR__ . '/../../cache/wp-gravatar-proxy/';
header('Content-type: image/png');
echo $cache->get_data($_GET['query'], 'https://secure.gravatar.com/avatar/' . $_GET['query']);