0
我試圖使用SLRequest發出推特請求,但每當我在請求中包含參數時,我得到的響應是{"errors":[{"message":"Could not authenticate you","code":32}]}
。如果我不包含參數,請求按預期工作。使用帶參數的SLRequest的Twitter請求中的錯誤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);
}];
}
}
}];
就是這樣,謝謝!不敢相信我沒有注意到它 –
:D它發生在我身上,正是在實際之前,所以不用擔心。 – brandonscript