Twitter API [1.1] 身份验证请求 —
Twitter API [1.1] Authentication Request —
在这方面需要大量帮助。基本上在我的应用程序中,我需要访问 twitter api,根据特定搜索标签获取前 50 个 post 并显示它们。身份验证的议程自然而然地出现了。现在这给我带来了严重的麻烦。我的代码似乎不起作用,因为 - 错误的身份验证数据 [215]。我使用了 TweetSharp 包来形成我的代码。
我会post这里--
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;
----> var tweets_search = twitterService.Search(new SearchOptions { Q = "#ClimateChange", Resulttype = TwitterSearchResultType.Popular, Count = 50 });
----> 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 版本中的哪条信息?不可能所有这些密钥和令牌、秘密等都是错误的。我正确地复制了它们,同时创建了我的 app.One 更重要的是,我正在从我的开发人员那里尝试这个。我本地机器上的环境;我对 windows 主机文件进行了编辑,使我的应用程序从该特定 IP 地址 运行 运行起来就像一个明确的 url。我也用过这个,同时在创建 Twitter 应用程序期间填写网站、域等字段的详细信息。
我使用了 rest client postman 和所有这些来交叉检查 api 请求的东西。是的,它会 return 215 code Bad AUthentication Data。有人告诉我,这可能是因为我电脑上的时钟与互联网时间不同步。所以我也这样做只是为了确定。依然没有。我真的很沮丧。请帮助我解决这个问题。我发现很难过去。
提前致谢,
您似乎在 进行搜索调用后调用 AuthenticateWith 。那行不通,如果您想以给定用户的身份进行搜索,则需要先调用 AuthenticateWith。
您还在使用当前版本的 TweetSharp 吗? original/official nugget 包不再受支持并且存在已知错误,尤其是在长整数处理方面。
在这方面需要大量帮助。基本上在我的应用程序中,我需要访问 twitter api,根据特定搜索标签获取前 50 个 post 并显示它们。身份验证的议程自然而然地出现了。现在这给我带来了严重的麻烦。我的代码似乎不起作用,因为 - 错误的身份验证数据 [215]。我使用了 TweetSharp 包来形成我的代码。
我会post这里--
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;
----> var tweets_search = twitterService.Search(new SearchOptions { Q = "#ClimateChange", Resulttype = TwitterSearchResultType.Popular, Count = 50 }); ----> 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 版本中的哪条信息?不可能所有这些密钥和令牌、秘密等都是错误的。我正确地复制了它们,同时创建了我的 app.One 更重要的是,我正在从我的开发人员那里尝试这个。我本地机器上的环境;我对 windows 主机文件进行了编辑,使我的应用程序从该特定 IP 地址 运行 运行起来就像一个明确的 url。我也用过这个,同时在创建 Twitter 应用程序期间填写网站、域等字段的详细信息。
我使用了 rest client postman 和所有这些来交叉检查 api 请求的东西。是的,它会 return 215 code Bad AUthentication Data。有人告诉我,这可能是因为我电脑上的时钟与互联网时间不同步。所以我也这样做只是为了确定。依然没有。我真的很沮丧。请帮助我解决这个问题。我发现很难过去。 提前致谢,
您似乎在 进行搜索调用后调用 AuthenticateWith 。那行不通,如果您想以给定用户的身份进行搜索,则需要先调用 AuthenticateWith。
您还在使用当前版本的 TweetSharp 吗? original/official nugget 包不再受支持并且存在已知错误,尤其是在长整数处理方面。