简体   繁体   English

C#-使用Twitterizer的“无效令牌”

[英]C# - “Invalid Token” using Twitterizer

I'm having issues with this piece of code: 我对这段代码有疑问:

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

Small program (as of request): 小程序(根据要求):

//cutted out default "using"'s
using Twitterizer;

namespace Mustache_Tweet_App
{
    public partial class Main : Form
    {
        // config
        OAuthTokens Tokens = new OAuthTokens();
        Tokens.AccessToken = "...";
        Tokens.AccessTokenSecret = "...";
        Tokens.ConsumerKey = "...";
        Tokens.ConsumerSecret = "...";
        Tokens.RequestToken = Twitterizer.OAuthUtility.GetRequestToken(Tokens.ConsumerKey, Tokens.ConsumerSecret, "");
        public Main()
        {
            InitializeComponent();
        }

        private void GetAuthKey_Click(object sender, EventArgs e)
        {
            String AuthUri = Twitterizer.OAuthUtility.BuildAuthorizationUri();
            System.Diagnostics.Process(AuthUri);
            MessageBox.Show("Please authorize and copy the key then click OK and paste it into the the key box.", "Info");
        } 
    }
}

Error: 错误:

****.Main.tokens' is a 'field' but is used like a 'type'
Invalid token '=' in class, struct, or interface member declaration

Get same error on all "tokens." 在所有“令牌”上都得到相同的错误。

Using Twitterizer 2-2-4. 使用Twitterizer 2-2-4。 also using Visual Studio 2012. 也使用Visual Studio 2012。

The OAuthTokens object does not have a property RequestToken OAuthTokens对象没有属性RequestToken

Also the OAuthTokens.ConsumerKey and OAuthTokens.ConsumerSecret don't have a get accessor, so you can't use them the way you are doing. 此外, OAuthTokens.ConsumerKeyOAuthTokens.ConsumerSecret也没有get访问器,因此您无法按自己的方式使用它们。

Why do you wan't the request tokens? 为什么不要求令牌? You already have them in the Tokens object. 您已经在Tokens对象中拥有了它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM