Objective c 使用带参数的SLRequest发送Twitter请求时出现错误32
我试图使用SLRequest发出twitter请求,但每当我在请求中包含参数时,我得到的响应是Objective c 使用带参数的SLRequest发送Twitter请求时出现错误32,objective-c,authentication,twitter,slrequest,Objective C,Authentication,Twitter,Slrequest,我试图使用SLRequest发出twitter请求,但每当我在请求中包含参数时,我得到的响应是{“errors”:[{“message”:“无法验证您”,“code”:32}]}。如果我不包括参数,请求将按预期工作 我尝试将参数作为查询字符串包含在URL中,但没有任何区别 这是我的密码: ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountType = [accountStore
{“errors”:[{“message”:“无法验证您”,“code”:32}]}
。如果我不包括参数,请求将按预期工作
我尝试将参数作为查询字符串包含在URL中,但没有任何区别
这是我的密码:
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *twitterAccounts = [accountStore accountsWithAccountType:accountType];
if (twitterAccounts.count == 0) {
NSLog(@"There are no Twitter accounts configured. You can add or create a Twitter account in Settings.");
}
else {
ACAccount *twitterAccount = [twitterAccounts firstObject];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/home_timeline.json"] parameters:@{@"count": @10}];
request.account = twitterAccount;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"%@", responseString);
}];
}
}
}];
在我看来,您无法将@10作为整数传递-请尝试将其作为字符串传递:@“10”
这里有一个就是这样,谢谢!真不敢相信我竟然没有注意到:事实上,我以前也有过这样的经历,所以不用担心。
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET
URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/home_timeline.json"]
parameters:@{@"count": @"10"}];
// ^