我尝试访问用户的iOS默认Twitter帐户。
我使用的是STTwitter库。下面的代码过去在我的设备上运行得很好,但现在不行了。返回的"oAuthToken“、"oAuthTokenSecret”、"userID“为空。但它仍在模拟器上工作
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
consumerKey:@"myConsumerKey"
consumerSecret:@"myConsumerSecret"];
[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {
STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitterAPIOS postReverseAuthAccessTokenWithAuthenticationHeader:authenticationHeader
successBlock:^(NSString *oAuthToken,
NSString *oAuthTokenSecret,
NSString *userID,
NSString *screenName) {
// use the tokens...
self.oAuthToken = oAuthToken;
self.oAuthTokenSecret = oAuthTokenSecret;
if(self.oAuthToken && self.oAuthTokenSecret){
completionHandler();
}
else{
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
[account renewCredentialsForAccount:[arrayOfAccounts firstObject] completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {
[self getUserTwitterDataFromPhoneSettingsInView:view WithCompletionHandler:completionHandler];
}];
}
} errorBlock:^(NSError *error) {
// Error
}];
} errorBlock:^(NSError *error) {
// no twitter account
// user denied access to their account(s)
}];
} errorBlock:^(NSError *error) {
// ...
}];发布于 2015-05-26 22:50:24
由于某些原因,在iOS设置中输入的推特帐户缺少'oauth_token‘属性,可能需要重新验证。一种可能的解决方法是转到iOS设置并再次设置帐户。现在,我将尝试找到一种在STTwitter中检测这种状态的方法。
https://stackoverflow.com/questions/30307062
复制相似问题