gpt4 book ai didi

iOS Twitter SLRequest 返回 url 域错误 -1012

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:21:11 25 4
gpt4 key购买 nike

我正在尝试执行反向 oauth 以获得服务器的 Twitter 访问 token 。

我已经想出了如何提交请求和接收响应,但是当我这样做时,它给我这个错误:

Error: The operation couldn’t be completed. (NSURLErrorDomain error -1012.)

我查了一下,它说这意味着用户已经取消了请求。我不确定这是怎么可能的,我不知道如何解决它。

这是我的代码:

NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];
NSNumber *timeStampObj = [NSNumber numberWithDouble: timeStamp];

NSString *oauth_nonce = [self genRandStringLength:32];
NSString *oauth_timestamp = [timeStampObj stringValue];

NSURL *feedURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/request_token"];

NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys: @"my key here", @"oauth_consumer_key", oauth_nonce, @"oauth_nonce", @"HMAC-SHA1", @"oauth_signature_method", oauth_timestamp, @"oauth_timestamp", @"1.0", @"oauth_version", @"reverse_auth", @"x_auth_mode", nil];

SLRequest *twitterFeed = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:feedURL parameters:parameters];

twitterFeed.account = self.userAccount;


// Making the request

[twitterFeed performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{

// Check if we reached the reate limit

if ([urlResponse statusCode] == 429) {
NSLog(@"Rate limit reached");
return;
}

// Check if there was an error

if (error) {
NSLog(@"The Error is: %@", error.localizedDescription);
return;
}

// Check if there is some response data
if (responseData) {

NSLog(@"%@", responseData);

}
});
}];

一定有一些简单的东西是我遗漏的,这让我无法完成一个项目。任何帮助都会很棒,谢谢!

最佳答案

错误代码 -1012 可能是由于身份验证质询造成的。就我而言,设置中存在一个 Twitter 帐户,但由于某种原因未登录。输入帐户密码后,一切正常。

关于iOS Twitter SLRequest 返回 url 域错误 -1012,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17643180/

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