Nil*_*bol 38 video objective-c ios instagram
我希望我的应用能够将视频上传到Instagram.
Instagram IPhone Hooks提供了如何使用iphone挂钩将照片上传到instagram的信息.我的问题是,是否有人有任何经验,如何完成相同但视频?
Nic*_*nen 44
Instagram的API不直接支持从第三方应用程序上传任何内容.因此,在向用户提供功能时,您必须做出一些丑陋的用户体验妥协.
首先,准备要上传到Instagram的视频并将路径存储到某个地方
其次,将其保存到用户的相机胶卷:
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(filePath)) {
UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
}
Run Code Online (Sandbox Code Playgroud)
第三,既然保存了视频,告诉用户为了将视频上传到他们的Instagram,他们必须在点击上传按钮后从他们的相机胶卷中选择它.
上传按钮只会执行以下操作:
NSURL *instagramURL = [NSURL URLWithString:@"instagram://camera"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
Run Code Online (Sandbox Code Playgroud)
Instagram API不支持通过任何API端点立即选择媒体进行上传,这是非常愚蠢的,但就目前而言,这是唯一的方法.
joh*_*g17 20
我有一个类似的问题:Instagram视频iPhone Hook,我想通了.有一个未记录的iPhone挂钩,允许您从iPhone照片卷自动选择资源,并预加载视频的标题.这应该为您提供Flipagrams应用程序与Instagram共享视频时的相同用户体验.
的Instagram://库AssetPath =资产库%3A%2F%2Fasset%2Fasset.mp4%3Fid%3D8864C466-A45C-4C48-B76F-E3C421711E9D%26ext%3Dmp4&InstagramCaption =有些%20Preloaded%20Caption?
NSURL *videoFilePath = ...; // Your local path to the video
NSString *caption = @"Some Preloaded Caption";
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:videoFilePath] completionBlock:^(NSURL *assetURL, NSError *error) {
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",[assetURL absoluteString].percentEscape,caption.percentEscape]];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
}];
Run Code Online (Sandbox Code Playgroud)
小智 10
尝试:
instagram://library?AssetPath=yourVideoPath
Run Code Online (Sandbox Code Playgroud)
我发现这里的解决方案:http://blog.horizon.camera/post/102273431070/video-share-objc-ios-instagram
针对iOS 9进行了更新.
首先,对于iOS9,您需要添加到您的Info.plist
文件中.添加LSApplicationQueriesSchemes
带有值的键a instagram
.这将使Instagram计划列入白名单.更多信息在这里.
这是基于johnnyg17的工作代码:
NSString *moviePath = @"<# /path/to/movie #>";
NSString *caption = @"<# Your caption #>";
NSURL *movieURL = [NSURL fileURLWithPath:moviePath isDirectory:NO];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:movieURL
completionBlock:^(NSURL *assetURL, NSError *error)
{
NSURL *instagramURL = [NSURL URLWithString:
[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",
[[assetURL absoluteString] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]],
[caption stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]]]
];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
else {
NSLog(@"Can't open Instagram");
}
}];
Run Code Online (Sandbox Code Playgroud)
样本instagramURL将是:
instagram://library?AssetPath=assets%2Dlibrary%3A%2F%2Fasset%2Fasset%2Emov%3Fid%3D69920271%2D2D44%2D4A84%2DA373%2D13602E8910B6%26ext%3Dmov&InstagramCaption=Super%20Selfie%20Dance%20%F0%9F%98%83
更新2016/5:请注意,ALAssetsLibrary
现在已弃用以保存到用户相册,现在推荐使用照片框架.
cod*_*cat -3
您可以通过媒体端点完成
https://api.instagram.com/v1/media/3?access_token=ACCESS-TOKEN
Run Code Online (Sandbox Code Playgroud)
获取有关媒体对象的信息。返回的类型键将允许您区分图像和视频媒体。
http://instagram.com/developer/endpoints/media/
此链接用于获取图像媒体 ID。但我希望同样的技术对视频有帮助。
NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=315"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
Run Code Online (Sandbox Code Playgroud)
优势信息:
归档时间: |
|
查看次数: |
22710 次 |
最近记录: |