【发布时间】:2012-02-13 17:21:34
【问题描述】:
不确定是否有人尝试过。我想使用手机用户无权访问的帐户访问 Twitter。
我查看它的方式是使用 OAth(令牌/秘密)添加一个 twitter 帐户
我可以使用以下代码添加帐户。
NSString *token = @"blahblahblah";
NSString *secret = @"blahblahblah";
ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountCredential *credential = [[ACAccountCredential alloc] initWithOAuthToken:token tokenSecret:secret];
ACAccountType *twitterAcctType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
ACAccount *newAccount = [[ACAccount alloc] initWithAccountType:twitterAcctType];
newAccount.credential = credential;
[store saveAccount:<#(ACAccount *)#> withCompletionHandler:<#^(BOOL success, NSError *error)completionHandler#>
[store saveAccount:newAccount withCompletionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"Account was saved!");
} else {
//something went wrong, check value of error
}
}];
但此代码将用户 ID 与 iphone 帐户存储中的密钥相关联。问题是,如果电话用户随后使用 twitter,则帐户特权仍然存在供他使用...
似乎没有实现store deleteAccount 方法
对于我的第二次尝试,我尝试仅使用创建的用户而不将其添加到帐户存储,但我认为 SaveAccount 方法是验证令牌和机密并获取用户名的方法...
任何提示???
【问题讨论】: