我正在尝试使用以下代码访问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,操作就会成功结束。
答案 0 :(得分:0)
试试这个
TwitterResponse twitterResponse1 = TwitterStatus.Update(令牌,"测试",新的StatusUpdateOptions {APIBaseAddress =" https://api.twitter.com/1.1/",UseSSL = true});