我使用 oauth 将我的网络应用程序连接到 twitter。它工作正常,但我需要定期重新授权应用程序。
我将密钥保存在会话中,但是当用户关闭页面时,这似乎被清除了。
我应该将密钥保存在额外的 cookie 中吗?
function access_token($tmhOAuth) {
$tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token'];
$tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret'];
$code = $tmhOAuth->request(
'POST',
$tmhOAuth->url('oauth/access_token', ''),
array(
'oauth_verifier' => $_REQUEST['oauth_verifier']
)
);
if ($code == 200) {
$_SESSION['access_token'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
unset($_SESSION['oauth']);
header('Location: ' . tmhUtilities::php_self());
} else {
outputError($tmhOAuth);
}
}