【问题标题】:Twitter SLRequest on OSX returns error 32OSX 上的 Twitter SLRequest 返回错误 32
【发布时间】:2013-11-30 17:23:23
【问题描述】:

在 OSX Mavericks 10.9 上执行 Twitter 的 SLRequest 会返回“无法对您进行身份验证”以及 任何 Twitter API 请求的错误代码 32。简单代码sn-p如下。

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);

让我感到奇怪的是,这个完全相同代码 sn-p 在 iOS 上运行没有任何问题。 ACAccount 似乎有效,preparedURLRequest 似乎具有所有 OAuth HTTP 标头,我不确定可能有什么问题......有什么想法吗?

【问题讨论】:

    标签: objective-c macos twitter osx-mavericks slrequest


    【解决方案1】:

    有点晚了,但是你需要指定 https。 :-) 是否需要更多来解决您的问题,我不知道!

    【讨论】:

      【解决方案2】:

      显然,这个 URL 不再存在于 HTTP 或 HTTPS 上,除非在问题发布时,Twitter 响应错误 32,我猜这是一个错误。

      无论如何,其他网址一切正常。

      【讨论】:

        猜你喜欢
        • 2013-10-05
        • 2014-08-03
        • 1970-01-01
        • 1970-01-01
        • 2013-06-22
        • 1970-01-01
        • 2011-11-11
        • 1970-01-01
        • 2019-01-25
        相关资源
        最近更新 更多