gpt4 book ai didi

c# - OAuth。推特。 StatusCode : 403. 需要 SSL。 C#

转载 作者:太空宇宙 更新时间:2023-11-03 14:55:50 25 4
gpt4 key购买 nike

我需要你的帮助!

我的代码:

 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);

可能是什么问题,我发送询问:

request {Method: POST, RequestUri: 'http://api.twitter.com/oauth/request_token', Version: 1.1, Content: , Headers: { Authorization: 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', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { connection: close date: Wed, 08 Apr 2015 09:06:50 GMT server: tsa_b set-cookie: guest_id=v1%3A142848401049508299; Domain=.twitter.com; Path=/; Expires=Fri, 07-Apr-2017 09:06:50 UTC x-connection-hash: 407806cc38f466361aa7e9efb2a35601 x-response-time: 5 Content-Length: 16 content-type: text/plain; charset=utf-8 } SSL is required

最佳答案

改变

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

关于c# - OAuth。推特。 StatusCode : 403. 需要 SSL。 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29511076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com