- (voID)tweet:(Nsstring *)IDentifIEr withCompletionHandler:(voID (^)())completionHandler {ACAccountStore *accountStore = [[ACAccountStore alloc] init];// Create an account type that ensures Twitter accounts are retrIEved.ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIDentifIEr:ACAccountTypeIDentifIErTwitter];// Request access from the user to use their Twitter accounts.[accountStore requestAccesstoAccountsWithType:accountType withCompletionHandler:^(BOol granted,NSError *error) { if(granted) { if (IDentifIEr) { // Get the List of Twitter accounts. NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; if ([accountsArray count] > 0) { // Grab the initial Twitter account to tweet from. NSURL *url = [NSURL URLWithString:@"https://API.twitter.com/1.1/statuses/update.Json"]; NSDictionary *dict = [NSDictionary dictionaryWithObject:[Nsstring stringWithFormat:@"Check out this great flick on BLA BLA %@",[BLA_URL stringByAppendingFormat:@"/%@/%@",@"flick",IDentifIEr]] forKey:@"status"]; SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:url parameters:dict]; [request setAccount:[accountsArray lastObject]]; [request performRequestWithHandler:^(NSData *responseData,NShttpURLResponse *urlResponse,NSError *error) { if ([urlResponse statusCode] == 200) { NSLog(@"TWEEET!"); } else { NSError *JsonError; ID data = [NSJsONSerialization JsONObjectWithData:responseData options:NSJsONReadingMutableLeaves error:&JsonError]; dispatch_async(dispatch_get_main_queue(),^{ UIAlertVIEw *alertVIEw = [[UIAlertVIEw alloc] initWithTitle:@"Twitter response" message:[Nsstring stringWithFormat:@"%d S: %d %@",[error code],[urlResponse statusCode],data] delegate:self cancelbuttonTitle:@"Ok" otherbuttonTitles:nil]; NSLog(@"NOOO TWEEET!"); [alertVIEw show]; completionHandler(); }); } }];...
和预检功能:
- (IBAction)twitterbuttonTapped:(ID)sender {if ([self.twitterbutton isSelected]) { [self.twitterbutton setSelected:NO];}else { [self.twitterbutton setSelected:YES]; ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIDentifIEr:ACAccountTypeIDentifIErTwitter]; [accountStore requestAccesstoAccountsWithType:accountType withCompletionHandler:^(BOol granted,NSError *error) { if (!granted) { [self.twitterbutton setSelected:NO]; UIAlertVIEw *alertVIEw = [[UIAlertVIEw alloc] initWithTitle:@"Twitter access" message:@"Please make sure you have allowed twitter for BLA BLA in your Settings." delegate:self cancelbuttonTitle:@"Ok" otherbuttonTitles:nil]; [alertVIEw performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO]; } }];}
}
解决方法 好的,我有答案!问题是其他iPhone的帐户数据不完整 – 您必须在设置应用中填写用户名和密码. 总结以上是内存溢出为你收集整理的ios – SLRequest – Twitter返回代码215(错误的身份验证数据)全部内容,希望文章能够帮你解决ios – SLRequest – Twitter返回代码215(错误的身份验证数据)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)