Twitter API [1.1]身份验证请求 -

时间:2017-07-24 13:41:54

标签: .net rest twitter-oauth restful-authentication tweetsharp

需要这方面的帮助。基本上在我的应用程序中,我需要访问twitter api,根据特定的搜索标签获取前50个帖子并显示它们。当然,身份验证的议程就出现了。现在这给我带来了严重的麻烦。我的代码看起来似乎并不是因为 - 认证数据不好[215]。我已经使用TweetSharp软件包来构建我的代码。

我会在这里发布 -

    public class TweetHelper
    public class TweetHelper
    {
        public static string _consumerKey = "whatever";
        public static string _consumerSecret = "whatever";
        public static string _accessToken = "whatever";
        public static string _accessTokenSecret = "whatever";

public static List<TwitterStatus> GetTweetList1()
    {
        TwitterService twitterService = new TwitterService(_consumerKey, _consumerSecret);
        int tweetcount = 1;

----&GT; var tweets_search = twitterService.Search(new SearchOptions {Q =&#34;#ClimateChange&#34;,Resulttype = TwitterSearchResultType.Popular,Count = 50});    ----&GT; twitterService.AuthenticateWith(_accessToken,_accessTokenSecret);

        List<TwitterStatus> resultList = new List<TwitterStatus>(tweets_search.Statuses);
        foreach (var tweet in tweets_search.Statuses)
        {
            try
            {
                tweet.User.ScreenName.ToString();
                tweet.User.Name.ToString();
                tweet.Text.ToString();
                tweet.RetweetCount.ToString();
                tweet.User.FavouritesCount.ToString();
                tweet.User.ProfileImageUrl.ToString();
                tweet.CreatedDate.ToString();
                ("https://twitter.com/intent/retweet?tweet_id=" + tweet.Id).ToString();
                ("https://twitter.com/intent/tweet?in_reply_to=" + tweet.Id).ToString();
                ("https://twitter.com/intent/favorite?tweet_id=" + tweet.Id).ToString();

                tweetcount++;
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        return resultList;


    }

}

我知道1.0 API版本已被Twitter弃用。而2.0还没有到来。所以它必须是1.1。如您所见,这两个是问题行,其中发生错误。我究竟做错了什么?或者API版本中的哪些信息是我错误接近的?它可能不是所有那些钥匙和令牌,秘密等都是错误的。在创建我的应用程序时,我正确地复制了它们。另外一件事是,我从我的开发中尝试这个。我本地机器上的环境;我在那里编辑了Windows主机文件,使我的应用程序从该特定IP地址运行,并且表现得像一个确定的URL。我也使用了这个,同时在创建twitter应用程序时填写了网站,域名等字段的详细信息。

我使用了休息的客户邮递员和所有这些来交叉检查api请求的事情。是的,它确实返回215个代码Bad AU认证数据。有人告诉我,这可能是因为我的电脑上的时钟没有与互联网时间同步。所以我也这样做只是为了确保。依然没有。我真的很沮丧。请帮我解决这个问题。我发现很难过去。 提前谢谢,

1 个答案:

答案 0 :(得分:0)

在进行搜索调用之后,您似乎正在调用AuthenticateWith 。如果您想要作为给定用户进行搜索,则需要首先调用AuthenticateWith。

您还在使用当前版本的TweetSharp吗?不再支持原始/官方块包,并且已知错误,特别是在长整数处理方面。