我想在 Objetive-C 中创建一个在 Twitter 帐户中即时“关注”的 Action ,但是当我启动我的应用程序时它崩溃了。谁能告诉我哪里出了问题?
它返回thread 1 exc_bad_access
。
- (IBAction)Twitter:(id)sender {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil
completion:^(BOOL granted, NSError *error) {
if(granted) {
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
if ([accountsArray count] > 0) {
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
[tempDict setValue:@"user" forKey:@"UserName"];
[tempDict setValue:@"true" forKey:@"follow"];
NSURL *URLTwitter = [NSURL URLWithString:@"https://api.twitter.com/1.1/friendships/create.format"];
SLRequest *postRequest = [SLRequest requestForServiceType:@"Twitter" requestMethod:SLRequestMethodPOST URL:URLTwitter parameters:tempDict];
[postRequest setAccount:twitterAccount];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output = [NSString stringWithFormat:@"HTTP response status: %li", [urlResponse statusCode]];
NSLog(@"%@", output);
}];
}
}
}];
}
最佳答案
您的推特网址不正确。应该是
https://api.twitter.com/1.1/friendships/create.json
关于ios - iOs 8 上的 Twitter API 有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27465090/