From 8ef04de7adcad6a7a967bb30338c001e23c9f9ac Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sat, 15 Feb 2020 16:53:15 +0800 Subject: [PATCH] Update common.php --- function/common.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/function/common.php b/function/common.php index 5581bd4..6470224 100644 --- a/function/common.php +++ b/function/common.php @@ -112,6 +112,11 @@ function is_guestup_path($path) return 0; } +function array_value_isnot_null($arr) +{ + return $arr!==''; +} + function curl_request($url, $data = false, $headers = []) { if (!isset($headers['Accept'])) $headers['Accept'] = '*/*'; @@ -146,6 +151,7 @@ function clearbehindvalue($path,$page1,$maxpage,$pageinfocache) for ($page=$page1+1;$page<$maxpage;$page++) { $pageinfocache['nextlink_' . $path . '_page_' . $page] = ''; } + $pageinfocache = array_filter($pageinfocache, 'array_value_isnot_null'); return $pageinfocache; } @@ -392,7 +398,7 @@ function main($path) } error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); $_SERVER['access_token'] = $ret['access_token']; - savecache('access_token', $_SERVER['access_token']); + savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300); if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+30*24*60*60 ]); }