Skip to content

Commit a3ac390

Browse files
committed
ad
1 parent 5915227 commit a3ac390

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":{"access_token":"W4XbgIP-ZF3xLLUqr0hNwPyK1KpVcDO4t7l81J3FWwFCZRr8CLKXiZRWZyUCENI-vQSvfr7U_IVhOeuPMSEIS_pMIjEvZiQKfmLH2qfrYOQSyI01s2AB-5mEE0WI9NUSHLSiAHADHO","expires_in":7200},"expire":7100}

src/FileCache/src/FileCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
/**
33
* php 文件缓存类
44
*/
5-
namespace niklaslu;
5+
// namespace niklaslu;
66

7-
class FileCache{
7+
class fileCache{
88

99
protected $filePath;
1010

src/Wechat.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function __construct($config){
4949
$this->redirect_uri = $config['redirect_uri'];
5050
$this->access_token = $this->get_access_token();
5151

52-
require_once 'FileCache/src/FileCache.php';
53-
$this->Cache = new FileCache();
54-
52+
// require_once dirname(__FILE__).'/FileCache/src/FileCache.php';
53+
// $this->Cache = new FileCache();
54+
5555
}
5656

5757
/**
@@ -67,7 +67,7 @@ public function return_access_token(){
6767
*/
6868
private function get_access_token(){
6969

70-
$data = $this->Cache('access_token_data');
70+
$data = $this->cache('access_token_data');
7171
if ($data){
7272
//从缓存中取
7373
$access_token = $data['access_token'];
@@ -85,7 +85,7 @@ private function get_access_token(){
8585
$data = $this->return_data($data);
8686
if ($data){
8787
$access_token = $data['access_token'];
88-
$this->Cache('access_token_data' , $data , $data['expires_in'] - 100);
88+
$this->cache('access_token_data' , $data , $data['expires_in'] - 100);
8989
return $access_token;
9090
}else{
9191
return false;
@@ -229,7 +229,7 @@ public function get_auth_user($openid , $access_token , $lang = 'zh_CN'){
229229
*/
230230
public function return_data($data){
231231

232-
if ($data['errcode']){
232+
if (isset($data['errcode'])){
233233
$this->error = $data['errmsg'];
234234
return false;
235235
}else{
@@ -337,7 +337,8 @@ public function http_post($url, $fields, $data_type='json') {
337337
*/
338338
public function cache($key , $value = null , $expire = 3600){
339339

340-
$cache = $this->Cache;
340+
require_once dirname(__FILE__).'/FileCache/src/FileCache.php';
341+
$cache = new \fileCache();
341342

342343
if ($value){
343344
$result = $cache->set($key, $value , $expire);
@@ -351,7 +352,9 @@ public function cache($key , $value = null , $expire = 3600){
351352

352353
public function cacheClear($key = null){
353354

354-
$cache = $this->Cache;
355+
require_once dirname(__FILE__).'/FileCache/src/FileCache.php';
356+
$cache = new \fileCache();
357+
355358
if ($key){
356359
$have = $cache->isHave($key);
357360
if ($have){

0 commit comments

Comments
 (0)