我需要你的帮助!
我的代码:
string twitterRequestTokenUrl = "http://api.twitter.com/oauth/request_token";
HttpRequestMessage request = new HttpRequestMessage();
string data = "oauth_consumer_key=\"" + oauth_consumer_key +
"\", oauth_nonce=\"" + oauth_nonce +
"\", oauth_signature=\"" + Uri.EscapeDataString(oauth_signature) +
"\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"" + oauth_timestamp +
"\", oauth_version=\"1.0\"";
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("OAuth", data);
request.RequestUri = new Uri(twitterRequestTokenUrl, UriKind.Absolute);
request.Method = new HttpMethod("POST");
var response = await httpClient.SendAsync(request);
可能是什么问题,我发来询问:
请求{方法:POST,RequestUri: 'http://api.twitter.com/oauth/request_token',版本:1.1,内容: ,标题:{授权:OAuth oauth_consumer_key = “*******************”, oauth_nonce = “NjM1NjQwOTY0MzAzMjMwNjgw”, oauth_signature = “nIQIuJqRLP2naUxgC0cTHqFqUkc%3D”, oauth_signature_method =“HMAC-SHA1”,oauth_timestamp =“1428485230”, oauth_version =“1.0”}} System.Net.Http.HttpRequestMessage
并得到以下答案:
StatusCode:403,ReasonPhrase:'Forbidden',版本:1.1,内容: System.Net.Http.StreamContent,Headers:{connection:close date:Wed, 08 Apr 2015 09:06:50 GMT服务器:tsa_b set-cookie: guest_id = V1%3A142848401049508299;域= .twitter.com;路径= /; Expires = Fri,07-Apr-2017 09:06:50 UTC x-connection-hash: 407806cc38f466361aa7e9efb2a35601 x-response-time:5内容长度:16 content-type:text / plain; charset = utf-8} SSL是必需的
答案 0 :(得分:0)
更改
string twitterRequestTokenUrl = "http://api.twitter.com/oauth/request_token";
到
string twitterRequestTokenUrl = "https://api.twitter.com/oauth/request_token";
应解决您的问题。
您看到状态代码为403的原因是" only SSL connections are allowed in Twitter API endpoints"