Ejemplo n.º 1
0
<?php

require_once "Cache_File.inc";
$cache = new Cache_File("second.cache", 10);
if ($text = $cache->get()) {
    print $text;
    exit;
}
$cache->begin();
?>
<html>
<body>
<!-- Cacheable for a day -->
Today is <?php 
echo strftime("%A, %B %e %Y %H:%M:%S");
?>
 
</body>
</html>
<?php 
$cache->end();
Ejemplo n.º 2
0
 public function wxAccessToken($appId = NULL, $appSecret = NULL)
 {
     $appId = is_null($appId) ? $this->appId : $appId;
     $appSecret = is_null($appSecret) ? $this->appSecret : $appSecret;
     $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appId . "&secret=" . $appSecret;
     $tKey = md5($url);
     $access_token = Cache_File::get($tKey, 3600);
     if (!empty($access_token)) {
         return $access_token;
     }
     $result = $this->wxHttpsRequest($url);
     //print_r($result);
     $jsoninfo = json_decode($result, true);
     $access_token = $jsoninfo["access_token"];
     Cache_File::set($tKey, $access_token);
     return $access_token;
 }