我想将带有标签的相机视频发布到Instagram上。我的应用程序使用以下代码。
- (void)share
{
NSString *Caption = @"#baby";
NSString *urlString = [NSString stringWithFormat:@"assets-library://asset/asset.mov?id=%@&ext=mov",assetLocalID];
NSURL *url = [NSURL URLWithString:urlString];
NSString *escapedString = [url.absoluteString URLEncode];
NSString *escapedCaption = [caption URLEncode];
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@", escapedString, escapedCaption]];
[[UIApplication sharedApplication] openURL:instagramURL];
}
- (NSString *)URLEncode
{
return [self URLEncodeUsingEncoding:NSUTF8StringEncoding];
}
- (NSString *)URLEncodeUsingEncoding:(NSStringEncoding)encoding {
return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (__bridge CFStringRef)self,NULL,(CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",CFStringConvertNSStringEncodingToEncoding(encoding));
}
但是标题没有添加到Instagram中。 我想添加标签。 我经历了https://www.instagram.com/developer/mobile-sharing/iphone-hooks/,但它没有帮助我!请分享您的想法。
答案 0 :(得分:0)
我想出了让我的应用程序接受instagram:// URL架构的想法。来自Flipagram的钩子在我的应用程序中打开如下:
的Instagram://库AssetPath =资产库%3A%2F%2Fasset%2Fasset.mp4%3Fid%3D8864C466-A45C-4C48-B76F-E3C421711E9D%26ext%3Dmp4&安培; InstagramCaption =有些%20Preloaded%20Caption
未记录的iPhone挂钩,允许您从iPhone照片卷中自动选择资源,并预加载视频的标题。这应该为您提供Flipagrams应用程序与Instagram共享视频时的相同用户体验。
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];
}
}];
效果很好!
更新:Instagram已删除了将标题传递到其应用的功能。现在最好的解决方案就是将所需的标题复制到粘贴板上。