0

我正在尝试使用以下代码访问用户的 Twitter 凭据:

ACAccountStore *account = [[ACAccountStore alloc] init];
    ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    [account requestAccessToAccountsWithType:accountType options:nil
                                  completion:^(BOOL granted, NSError *error)
     {
         if (granted)
         {
             NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];

             if ([arrayOfAccounts count] > 0)
             {
                 ACAccount *twitterAccount = [arrayOfAccounts lastObject];

                 NSURL *requestURL = [NSURL URLWithString:@"https:api.twitter.com/1.1/account/verify_credentials.json"];


                 SLRequest *getRequest = [SLRequest
                                           requestForServiceType:SLServiceTypeTwitter
                                           requestMethod:SLRequestMethodGET
                                           URL:requestURL parameters:nil];


                 [getRequest setAccount:twitterAccount];


                 [getRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {

                     NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:nil];
                     NSLog(@"Twitter Response : %@ ",json);


                 }];

             }
         };
     }];
}

使用此代码,我收到此错误:

Twitter Response : {
errors =     (
            {
        code = 32;
        message = "Could not authenticate you";
    }
);

}

奇怪的是,如果我尝试发推文或访问 Twitter 的某个其他端点,其中需要有一个 oauth-token,则操作成功结束。

4

1 回答 1

0

尝试这个

TwitterResponse twitterResponse1 = TwitterStatus.Update(tokens, "test", new StatusUpdateOptions { APIBaseAddress = " https://api.twitter.com/1.1/ ", UseSSL = true });

于 2014-05-29T09:47:53.723 回答