不确定您的应用的目标是什么,但要回答您的一些问题 – 关注:
Do tokens have to be hard coded?
不,根据您编码的应用程序的性质,您可以在通过webform执行程序时请求此数据,或者在GUI中将文本字段包含在另一个文件中并对其进行加密或导入其所在的文件并使用它. .
I have the OAuth and access tokens hard coded right now, but the token
seems to expire every 24 hours. What can I do to renew the token
programatically?
POST oauth/request_token Allows a Consumer application to obtain an
OAuth Request Token to request user authorization. This method
fulfills Section 6.1 of the OAuth 1.0 authentication flow. It is
strongly recommended you use HTTPS for all OAuth authorization steps.
Usage Note: Only ASCII values are accepted for the oauth_nonce
关于访问令牌到期:
How long does an access token last? We do not currently expire access
tokens. Your 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. as
per twitter:
What do I do if an access token I have becomes invalid? You should
plan that a user’s access token may become invalid at any time and you
will need to re-authorize for that user in the case that it does.
Ensuring you handle this situation gracefully is imperative for a
quality user experience.
API请求包含无效的承载令牌
使用不正确或已撤销的承载令牌发出API请求将导致:
HTTP / 1.1 401未经授权
Content-Type:application / json;字符集= utf-8的
内容长度:61
…
{“errors”:[{“message”:“令牌无效或过期”,“代码”:89}]}