【发布时间】:2016-08-02 15:35:25
【问题描述】:
基本上,我想要做的是从用户那里获取最近的推文并与他们一起做事。我正在使用基于 PIN 的身份验证的 Tweetinvi,如网站上所述,如下所示:
// Create a new set of credentials for the application
var appCredentials = new TwitterCredentials("CONSUMER_KEY", "CONSUMER_SECRET");
// Go to the URL so that Twitter authenticates the user and gives him a PIN code
var url = CredentialsCreator.GetAuthorizationURL(appCredentials);
// This line is an example, on how to make the user go on the URL
Process.Start(url);
// Ask the user to enter the pin code given by Twitter
var pinCode = Console.ReadLine();
// With this pin code it is now possible to get the credentials back from Twitter
var userCredentials = CredentialsCreator.GetCredentialsFromVerifierCode(pinCode, appCredentials);
// Use the user credentials in your application
Auth.SetCredentials(userCredentials);
现在的问题是,每次通过浏览器启动我的应用程序时,我都必须登录并连接到 Twitter,这有点烦人。我尝试将身份验证详细信息保存在文本文件(消费者密钥、消费者秘密、访问令牌、访问令牌秘密)中,然后将信息插入到 appCredentials 和 userCredentials 中,但没有结果,因为我不断收到 TwitterNullCredentialsException。那么如何保存我的凭据,这样我就不必在每次启动时重新连接?
【问题讨论】:
-
我提供的解决方案好运吗?
-
@Linvi 现在可以正常工作了,谢谢