How can I persit the ouath tokens so that Im can use them in future?
I am develop开发者_JAVA技巧ing an application which require integration with twitter. I am using twitter4j api .
I have to persist the ouath tokens so that my application can interact with twitter in future. I save the access token and access token secret . However when I am reusing them I am getting an exception token expire .
Could you please let me know the way I can reuse them and what is the expiration period of the ouath tokens ?
from Twitter's OAuth FAQ:
How long does an access token last?
We do not currently expire access tokens. You access token will be invalid if a user explicitly rejects your application from their settings or if a Twitter admin suspends your application. If your application is suspended there will be a note on your application page saying that it has been suspended.
You should use cookies to save your oauth token and oauth token secret and then make subsequent requests using by retrieving cookie data.
Like in php , i use it like this:
setcookie('oauth_token', $token->oauth_token);
setcookie('oauth_token_secret', $token->oauth_token_secret);
You can access these values by $_COOKIE['oauth_token'] and $_COOKKIE['oauth_token_secret'].but this is in php. You should see how you have to do it in JAVA.
Hope this helps you Anshul.
精彩评论