使用Fabric API在Twitter上分享视频,而不需要作曲家iOS

使用Fabric API在Twitter上分享视频,而不需要作曲家iOS,第1张

概述通过REST API for Twitter的视频上传在一月中可用,但不支持Fabric框架: link! 根据 documentation需要通过命令进行3个呼叫:INIT,APPEND和FINALIZE. -(void) shareOnTwitterWithVideo:(NSDictionary*) params{ NSString *text = params[@"text"] 通过REST API for Twitter的视频上传在一月中可用,但不支持Fabric框架:
link!解决方法 根据 documentation需要通过命令进行3个呼叫:INIT,APPEND和FINAliZE.
-(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",@"total_bytes":lengthVIDeo};        NSURLRequest *preparedRequest = [clIEnt URLRequestWithMethod:@"POST" URL:url parameters:message error:&error];        [clIEnt sendTwitterRequest:preparedRequest 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};                NSURLRequest *preparedRequest = [clIEnt URLRequestWithMethod:@"POST" URL:url parameters:message error:&error];                [clIEnt sendTwitterRequest:preparedRequest completion:^(NSURLResponse *urlResponse,NSError *error){                    if(!error){                        clIEnt = [[Twitter sharedInstance] apiclient];                        NSError *error;                        // Third call with command FINAliZE                        message = @{@"command" : @"FINAliZE",@"media_ID" : mediaID};                        NSURLRequest *preparedRequest = [clIEnt URLRequestWithMethod:@"POST" URL:url parameters:message error:&error];                        [clIEnt sendTwitterRequest:preparedRequest 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];                                NSURLRequest *preparedRequest = [clIEnt URLRequestWithMethod:@"POST" URL:url parameters:message error:&error];                                [clIEnt sendTwitterRequest:preparedRequest 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所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1111136.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存