2013-03-02 53 views
2

我创建了一个新应用程序并使用Twitter注册了它,以获取使用者密钥,使用者密钥,令牌和令牌密钥。然后我添加了对TweetSharp的引用。接下来,我使用https://github.com/danielcrenna/tweetsharp中的代码说明“验证客户端应用程序(即桌面)”。如何使用TweetSharp验证Twitter

它总是打开的页面在标题栏中没有键。我注意到步骤1中的oAuthRequestToken具有两个令牌/令牌密钥属性,并且都没有设置。所以我手动添加行来设置这两个。我再次尝试。这一次在浏览器中打开的Url看起来已经完成。

我看过的所有内容都是“Whoa there!”此页面的请求标记无效,可能已经被使用或过期,因为它太旧了,请返回到发送给您的站点或应用程序,再试一次,这可能只是一个错误。“

我已经尝试重新创建令牌,并发送密钥以及令牌,以防万一我不理解它。我完全失去了。开始就不难!

任何想法?

回答

1

我不确定你的问题在哪里,但我会尽力帮忙。这里是我测试过的样品,适合我。我从社区获得了它。不要忘记将密钥放在app.config文件中。

 TwitterClientInfo twitterClientInfo = new TwitterClientInfo(); 
     twitterClientInfo.ConsumerKey = ConsumerKey; //Read ConsumerKey out of the app.config 
     twitterClientInfo.ConsumerSecret = ConsumerSecret; //Read the ConsumerSecret out the app.config 

     TwitterService twitterService = new TwitterService(twitterClientInfo); 


     //Now we need the Token and TokenSecret 

     //Firstly we need the RequestToken and the AuthorisationUrl 
     OAuthRequestToken requestToken = twitterService.GetRequestToken(); 
     string authUrl = twitterService.GetAuthorizationUri(requestToken).ToString(); 

     //authUrl is just a URL we can open IE and paste it in if we want 
     Process.Start(authUrl); //Launches a browser that'll go to the AuthUrl. 

     //Allow the App 
     //ask for the pin 
     //string pin = ... 


     OAuthAccessToken accessToken = twitterService.GetAccessToken(requestToken, pin); 

     string token = accessToken.Token; //Attach the Debugger and put a break point here 
     string tokenSecret = accessToken.TokenSecret; //And another Breakpoint here 


     twitterService.AuthenticateWith(AccessToken, AccessTokenSecret); 

希望它有帮助。 祝你好运。

+0

对不起,但这里的针是什么? – 2017-06-02 07:12:52