简体   繁体   English

Linq To Twitter错误-“远程服务器返回错误:(400)错误的请求”

[英]Linq To Twitter error - “The remote server returned an error: (400) Bad Request”

I'm just trying to simply get the 3 latest tweets for a Twitter account: 我只是想简单地获取一个Twitter帐户的3条最新推文:

List<string> tweets = new List<string>();
var twitterCtx = new TwitterContext();

statusTweets =
    tweet in twitterCtx.Status
    where tweet.Type == StatusType.User &&
        tweet.Count == 3 &&
        tweet.ID == "shanselman"
    select tweet;

foreach (var statusTweet in statusTweets)
{
    tweets.Add(statusTweet.Text);
}

But I'm getting this error when I reach the line with the foreach loop: 但是当我到达foreach循环的行时,我得到了这个错误:

The remote server returned an error: (400) Bad Request. 远程服务器返回错误:(400)错误的请求。

Description: An unhandled exception occurred during the execution of the current web request. 说明:执行当前Web请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code. 请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request. 异常详细信息:System.Net.WebException:远程服务器返回错误:(400)错误的请求。

Anyone know what I'm doing wrong? 有人知道我在做什么错吗?

LINQ to Twitter supports Twitter API v1.1, which requires OAuth authentication on every request. LINQ to Twitter支持Twitter API v1.1,该API要求对每个请求进行OAuth身份验证。 I understand that the error message, 400 Bad Request, is a little confusing because a 401 Unauthorized lets you know that you have an authorization problem. 我知道错误消息400 Bad Request有点令人困惑,因为401 Unauthorized让您知道您有授权问题。 Maybe the 400 is because if you don't try to authenticate at all, the request isn't built properly. 可能是400,是因为如果您根本不尝试进行身份验证,则请求构建不正确。 Anyway, I'm sure that your problem is that you need to go through the authorization process with OAuth. 无论如何,我确定您的问题是您需要使用OAuth进行授权过程。 I wrote some OAuth documentation on the LINQ to Twitter Securing your Application page. 我在LINQ to Twitter的“ 保护您的应用程序”页面上写了一些OAuth文档。

The downloadable source code has examples and there's a sample page on the site. 可下载的源代码包含示例,网站上有一个示例页面

Once you start using OAuth, you might run into some 401 Unauthorized errors and will want to review the LINQ to Twitter FAQ . 一旦开始使用OAuth,您可能会遇到一些401未经授权的错误,并希望查看LINQ to Twitter常见问题解答

Joe

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

相关问题 (400)错误的请求-&gt;远程服务器返回错误:(400)错误的请求 - (400) Bad Request -> The remote server returned an error: (400) Bad Request 远程服务器返回错误:(400)错误请求? - The remote server returned an error: (400) Bad Request? 远程服务器返回错误(400)错误的请求 - the remote server returned an error (400) bad request Http Web请求远程服务器返回错误:(400)错误的请求。 Twitter时间轴 - Http web request The remote server returned an error: (400) Bad Request. twitter timeline 远程服务器返回错误:(400)Bad Request.System.Net.HttpWebResponse Hammock Twitter API - The remote server returned an error: (400) Bad Request.System.Net.HttpWebResponse Hammock Twitter API WebClient UploadFile远程服务器返回错误:(400)错误的请求 - WebClient UploadFile The remote server returned an error: (400) Bad Request 远程服务器返回错误(400)错误的请求,状态为ProtocolError - The remote server returned an error (400) Bad Request, status ProtocolError C#FCM:远程服务器返回错误:(400)错误的请求 - C# FCM : The remote server returned an error: (400) Bad Request 远程服务器返回错误:(400)错误请求。 - The remote server returned an error: (400) Bad Request. 如何修复:远程服务器返回错误:(400) 错误请求 - HOW TO FIX: The remote server returned an error: (400) Bad Request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM