Posting a Tweet to a Twitter Account Using DotNetOpenAuth

I am trying to find an example of how to just tweet on my Twitter account using C # and DotNetOpenAuth. I want to do this from a WinForms application. The examples I found seem to use ASP.NET and WebForms. In particular, I get to the "verifier code". Here is the code that I still have:

private McMurryTokenManager TokenManager { get { McMurryTokenManager tokenManager = null; string consumerKey = ConsumerKey; string consumerSecret = ConsumerSecret; if (!string.IsNullOrEmpty(consumerKey)) { tokenManager = new McMurryTokenManager { ConsumerKey = consumerKey, ConsumerSecret = consumerSecret }; } return tokenManager; } } public Form1() { InitializeComponent(); var twitter = new DesktopConsumer(TwitterConsumer.ServiceDescription, TokenManager); string requestToken; twitter.RequestUserAuthorization(null, null, out requestToken); var accessTokenResponse = twitter.ProcessUserAuthorization(requestToken, null); } 

I get an error when the verifier code cannot be null.

+4
source share
1 answer

Here is what you need to do:

  • The RequestUserAuthorization method returns the URL to the authorization page.
  • You should redirect the user to this page, usually Process.Start (url), where the user authorizes your application.
  • Twitter redirects the user to a multi-digit page, which is a verifier.
  • After you send the user to the authorization page, your application must wait with a dialog or invitation so that the user can enter the verifier and send it to your application.
  • Once you have the verifier, pass it as the 2nd argument to ProcessUserAuthorization.

Here is a blog post that says something similar and has sample code:

http://whelkaholism.blogspot.com/2010/08/c-doing-stuff-with-google-using-oauth.html

+1
source

Source: https://habr.com/ru/post/1433884/


All Articles