在OSXMavericks10.9上为SLRequest执行一个TwitterforTwitter10.9返回“无法对您进行身份验证”,错误代码32用于任何Twitter请求。下面是简单的代码片段。
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
ACAccount *account = [accountsArray lastObject];
NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1.1/help/test.json"];
SLRequest *r = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:url parameters:nil];
r.account = account;
[r performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSLog(@"%@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
dispatch_semaphore_signal(semaphore);
}];
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);令我感到奇怪的是,这个完全相同的代码片段在iOS上工作,没有任何问题。ACAccount似乎是有效的,preparedURLRequest似乎有所有的OAuth headers,我不确定什么可能是错误的.有什么想法吗?
发布于 2014-02-19 14:46:15
显然,这个URL不再存在于HTTP或HTTPS上,除非在发布问题时,Twitter的响应是错误32,我猜这是一个错误。
不管怎么说,其他URL都能正常工作。
发布于 2014-02-11 20:10:17
有点晚了,但是您需要指定https。
https://stackoverflow.com/questions/20032901
复制相似问题