CodeS adlı üyeden alıntı: mesajı görüntüle
ini, env yada doğrudan txt gibi key=value tarzı statik bir dosyada tutulabilir. güvenlik için dosyaya doğrudan erişim apache yada nginx konfigrasyonlarıyla engellenebilir

aşağıda kod örneği vereceğim bu örneği kendine göre düzenleyebilirsin
checkTokens methodu içerisindeki 7200 yazan kısmı token exp süresi ne ise ona göre revize edebilirsin.
request methodunuda yine kendine göre revize edersin hatta bu methodu sadece token oluşturma değil apiye atılacak tüm istekler için kullanacak hal getirebilirsin.

örnek:
<?phpclass Request{    public $BASE_URL = 'https://localhost/api/';    public $config;    public $access_token;    public $file = 'token.ini';    public function __construct($config)    {        $this->config = $config;        if (function_exists('storage_path')) {            $this->file = './token.ini';        }        $this->checkTokens();    }    public function checkTokens()    {        try {            $tokens = parse_ini_file($this->file);        } catch (Exception $e) {            @unlink($this->file);        }        if (!isset($tokens['access_token']) || !isset($tokens['created_at'])) {            return $this->authorize();        }        if (time() - (int)$tokens['created_at'] > 7200) {            return $this->authorize();        }        $this->access_token = $tokens['access_token'];        return $tokens;    }    public function authorize()    {        $resp = $this->authWithPassword();        if (isset($resp['access_token'])) {            $token = '';            foreach ($resp as $key => $value) {                $token .= $key . '=' . $value . "n";            }            file_put_contents($this->file, $token);            $this->access_token = $resp['access_token'];        }        return false;    }    public function request($path, $params = null, $method = 'POST')    {        //burada apiye istek atar apiden gelen veriyi işlersin    }    private function authWithPassword()    {        $path = $this->BASE_URL . '/access_token';        return $this->request($path, $this->config, 'POST');    }}
Çok teşekkürler, gayet açıklayıcı olmuş.
Ben bunu ön muhasebe projemde e-fatura entegratör bağlantısında kullanmayı düşünüyorum. Ama sizin örnek verdiğiniz mantık ile her bir user'a txt oluştursak olabilir sanırım.