|
@@ -80,7 +80,7 @@ class Wechat
|
|
*
|
|
*
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- private function save($type = 'ticket', $value, $expires = false, $interval = 2000, $data = false)
|
|
|
|
|
|
+ private function save($type = 'ticket', $value, $expires = false, $interval = 2000, $data = false, $state = false)
|
|
{
|
|
{
|
|
if (strpos($type, '.')) {
|
|
if (strpos($type, '.')) {
|
|
$temp = explode('.', $type);
|
|
$temp = explode('.', $type);
|
|
@@ -111,7 +111,9 @@ class Wechat
|
|
|
|
|
|
$update = false;
|
|
$update = false;
|
|
|
|
|
|
- if ($info && time() - $info['mdate'] >= $info['expires']) {
|
|
|
|
|
|
+ if ($state == true) {
|
|
|
|
+ $update = true;
|
|
|
|
+ } elseif ($info && time() - $info['mdate'] >= $info['expires']) {
|
|
$update = true;
|
|
$update = true;
|
|
} elseif($info) {
|
|
} elseif($info) {
|
|
return $info;
|
|
return $info;
|
|
@@ -192,7 +194,7 @@ class Wechat
|
|
*
|
|
*
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- public function oauth($param, $interval = 2000)
|
|
|
|
|
|
+ public function oauth($param, $interval = 2000, $state = false)
|
|
{
|
|
{
|
|
if (is_array($param) && isset($param['auth_code'])) {
|
|
if (is_array($param) && isset($param['auth_code'])) {
|
|
$result = $this->curl('oauth.oauth', $param);
|
|
$result = $this->curl('oauth.oauth', $param);
|
|
@@ -207,7 +209,7 @@ class Wechat
|
|
$param = array();
|
|
$param = array();
|
|
$param['id'] = $id;
|
|
$param['id'] = $id;
|
|
}
|
|
}
|
|
- return $this->save('oauth.refresh', false, false, $interval, $param);
|
|
|
|
|
|
+ return $this->save('oauth.refresh', false, false, $interval, $param, $state);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -271,10 +273,14 @@ class Wechat
|
|
}
|
|
}
|
|
//print_r($param);die;
|
|
//print_r($param);die;
|
|
if (isset($result['errcode']) && $result['errcode'] != 0) {
|
|
if (isset($result['errcode']) && $result['errcode'] != 0) {
|
|
- $result = $param + $result;
|
|
|
|
- Dever::log($result);
|
|
|
|
- if ($alert) {
|
|
|
|
- Dever::alert(json_encode($result, JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
+ if ($result['errcode'] == '40001') {
|
|
|
|
+ $this->oauth($param['id'], 2000, true);
|
|
|
|
+ } else {
|
|
|
|
+ $result = $param + $result;
|
|
|
|
+ Dever::log($result);
|
|
|
|
+ if ($alert) {
|
|
|
|
+ Dever::alert(json_encode($result, JSON_UNESCAPED_UNICODE));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|