【发布时间】:2014-08-03 00:39:15
【问题描述】:
我正在尝试使用 SLRequest 发出 twitter 请求,但每当我在请求中包含参数时,我得到的响应都是 {"errors":[{"message":"Could not authenticate you","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);
}];
}
}
}];
【问题讨论】:
标签: objective-c authentication twitter slrequest