2013-03-02 4 views
2

새로운 애플리케이션을 생성하고 Twitter에 등록하여 소비자 키, 소비자 키 비밀, 토큰 및 토큰 비밀을 얻었습니다. 그런 다음 TweetSharp에 대한 참조를 추가했습니다. 다음으로 나는 https://github.com/danielcrenna/tweetsharp에서 "클라이언트 응용 프로그램 (즉, 데스크탑) 인증"이라는 코드를 사용했습니다.TweetSharp로 트위터를 인증하는 방법

항상 열리는 페이지는 제목 표시 줄에 키가 없습니다. 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

미안하지만 핀은 무엇입니까? –