function get_access_token() { $key = ‘access_token‘; $access_token = Session::get($key); if (!empty($access_token) && $access_token !== false) return $access_token; $corp_info=C(‘wxinfo‘); // var_dump ($corp_info); $corp_id = $corp_info[‘CorpID‘]; $Secret = $corp_info[‘Secret‘]; if (empty ( $corp_id ) || empty ( $Secret )) { Session::set($key, 0, 7200); return 0; } $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={$corp_id}&corpsecret={$Secret}"; $tempArr = json_decode ( file_get_contents ( $url ), true ); if (@array_key_exists ( $key, $tempArr )) { Session::set($key, $tempArr [‘access_token‘], 7200); return $tempArr [‘access_token‘]; } else { return 0; } }