Storing Twitter access token using Twitterizer

偶尔善良 提交于 2019-12-04 21:52:17

You should store the 4 properties returned by the OAuthUtility.GetAccessToken method in your database. All authorized API calls require an OAuthTokens object. All you need to do is instantiate a new object, set the properties to the values you have (consumer token and access token), then pass your instance to the method.

For example:

OAuthTokens tokens = new OAuthTokens();
tokens.AccessToken = "XXX";
tokens.AccessTokenSecret = "XXX";
tokens.ConsumerKey = "XXX";
tokens.ConsumerSecret = "XXX";

TwitterResponse<TwitterUser> showUserResponse = TwitterUser.Show(tokens, "twit_er_izer");

Or, if you're using VB.NET:

Dim tokens As New OAuthTokens()
tokens.AccessToken = "XXX"
tokens.AccessTokenSecret = "XXX"
tokens.ConsumerKey = "XXX"
tokens.ConsumerSecret = "XXX"

Dim showUserResponse As TwitterResponse(Of TwitterUser) = TwitterUser.Show(tokens, "twit_er_izer")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!