Skip to content

Commit

Permalink
fix overtrue:#4 for PHP5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNorthMemory committed May 18, 2015
1 parent 3150f16 commit 970352e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/Wechat/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ public function getTicket()
$key = 'overtrue.wechat.card.api_ticket';

// for php 5.3
$http = $this->http;
$cache = $this->cache;
$http = $this->http;
$cache = $this->cache;
$apiTicket = self::API_TICKET;

return $this->ticket = $this->cache->get(
$key, function ($key) use ($http, $cache) {
$key, function ($key) use ($http, $cache, $apiTicket) {

$result = $http->get(self::API_TICKET);
$result = $http->get($apiTicket);

$cache->set($key, $result['ticket'], $result['expires_in']);

Expand Down
9 changes: 5 additions & 4 deletions src/Wechat/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ public function lists()
$key = 'overtrue.wechat.colors';

// for php 5.3
$http = $this->http;
$cache = $this->cache;
$http = $this->http;
$cache = $this->cache;
$apiList = self::API_LIST;

return $this->cache->get(
$key, function ($key) use ($http, $cache) {
$key, function ($key) use ($http, $cache, $apiList) {

$result = $http->get(self::API_LIST);
$result = $http->get($apiList);

$cache->set($key, $result['colors'], 86400);// 1 day

Expand Down
5 changes: 3 additions & 2 deletions src/Wechat/Js.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ public function getTicket()
$appId = $this->appId;
$appSecret = $this->appSecret;
$cache = $this->cache;
$apiTicket = self::API_TICKET;

return $this->cache->get(
$key, function ($key) use ($appId, $appSecret, $cache) {
$key, function ($key) use ($appId, $appSecret, $cache, $apiTicket) {
$http = new Http(new AccessToken($appId, $appSecret));

$result = $http->get(self::API_TICKET);
$result = $http->get($apiTicket);

$cache->set($key, $result['ticket'], $result['expires_in']);

Expand Down

0 comments on commit 970352e

Please sign in to comment.