大佬教程收集整理的这篇文章主要介绍了使用Fabric API在Twitter上分享视频,而不需要作曲家iOS,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
-(void) shareOnTwitterWithVideo:(NSDictionary*) params{ NSString *text = params[@"text"]; NSData* dataVideo = params[@"video"]; NSString *lengthVideo = [NSString StringWithFormat:@"%d",[params[@"length"] intValue]]; NSString* url = @"https://upload.twitter.com/1.1/media/upload.json"; __block NSString *mediaId; if([[Twitter sharedInstance] session]){ TWTRAPIClient *client = [[Twitter sharedInstance] APIClient]; NSError *error; // First call with command INIT NSDictionary *message = @{ @"status":text,@"command":@"INIT",@"media_type":@"video/mp4",@"@R_959_10586@l_bytes":lengthVideo}; NSURL@R_801_10613@est *prepared@R_801_10613@est = [client URL@R_801_10613@estWithMethod:@"POST" URL:url parameters:message error:&error]; [client sendTwitter@R_801_10613@est:prepared@R_801_10613@est completion:^(NSURLResponse *urlResponse,NSData *responseData,NSError *error){ if(!error){ NSError *jsonError; NSDictionary *json = [NSJSONserialization JSONObjectWithData:responseData options:0 error:&jsonError]; mediaId = [json objectForKey:@"media_id_String"]; client = [[Twitter sharedInstance] APIClient]; NSError *error; NSString *videoString = [dataVideo base64EncodedStringWithOptions:0]; // Second call with command APPEND message = @{@"command" : @"APPEND",@"media_id" : mediaId,@"segment_index" : @"0",@"media" : videoString}; NSURL@R_801_10613@est *prepared@R_801_10613@est = [client URL@R_801_10613@estWithMethod:@"POST" URL:url parameters:message error:&error]; [client sendTwitter@R_801_10613@est:prepared@R_801_10613@est completion:^(NSURLResponse *urlResponse,NSError *error){ if(!error){ client = [[Twitter sharedInstance] APIClient]; NSError *error; // Third call with command FINALIZE message = @{@"command" : @"FINALIZE",@"media_id" : mediaId}; NSURL@R_801_10613@est *prepared@R_801_10613@est = [client URL@R_801_10613@estWithMethod:@"POST" URL:url parameters:message error:&error]; [client sendTwitter@R_801_10613@est:prepared@R_801_10613@est completion:^(NSURLResponse *urlResponse,NSError *error){ if(!error){ client = [[Twitter sharedInstance] APIClient]; NSError *error; // publish video with status NSString *url = @"https://api.twitter.com/1.1/statuses/update.json"; NSMutableDictionary *message = [[NSMutableDictionary alloc] initWithObjectsAndKeys:text,@"status",@"true",@"wrap_links",mediaId,@"media_ids",nil]; NSURL@R_801_10613@est *prepared@R_801_10613@est = [client URL@R_801_10613@estWithMethod:@"POST" URL:url parameters:message error:&error]; [client sendTwitter@R_801_10613@est:prepared@R_801_10613@est completion:^(NSURLResponse *urlResponse,NSError *error){ if(!error){ NSError *jsonError; NSDictionary *json = [NSJSONserialization JSONObjectWithData:responseData options:0 error:&jsonError]; NSLog(@"%@",json); }else{ NSLog(@"Error: %@",error); } }]; }else{ NSLog(@"Error command FINALIZE: %@",error); } }]; }else{ NSLog(@"Error command APPEND: %@",error); } }]; }else{ NSLog(@"Error command INIT: %@",error); } }]; } }
以上是大佬教程为你收集整理的使用Fabric API在Twitter上分享视频,而不需要作曲家iOS全部内容,希望文章能够帮你解决使用Fabric API在Twitter上分享视频,而不需要作曲家iOS所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。