InstagramvideoiPhone挂钩

目前最好的解决scheme:

https://stackoverflow.com/a/21888830/1786820

我试图做一个更好的,通过从PhotoRoll中预先select的video文件和预加载的标题打开Instagram应用程序。 在Flipagram应用程序,他们做到这一点。 当你点击一个video分享,他们保存你的相机胶卷,build议一个标题,然后直接进入Instagram的应用程序照片select屏幕,与预选的video。 即使video不是PhotoRoll中的最新媒体,也可以沿着Flipagram应用程序中准备的标题正确突出显示正确的video。

这可能是一个无证的iPhone挂钩?

任何帮助表示赞赏。

我想出了让我的应用程序接受instagram:// URL架构的想法。 Flipagram的钩子在我的应用程序中打开如下:

的Instagram://库AssetPath =资产库%3A%2F%2Fasset%2Fasset.mp4%3Fid%3D8864C466-A45C-4C48-B76F-E3C421711E9D%26ext%3Dmp4&InstagramCaption =有些%20Preloaded%20Caption?

未公开的iPhone挂钩,允许您从iPhones照片卷中自动select资源,并为video预加载标题。 这应该给你相同的用户体验,Flipagram应用程序与Instagram分享video。

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已经删除了将标题传递给他们的应用程序的能力。 现在最好的解决办法就是将所需的标题复制到粘贴板上。

答案是,它根本不是从相机胶卷中拉出video,而只是看起来像。

文档在这里: http : //instagram.com/developer/mobile-sharing/iphone-hooks/

相关位是“文档交互”的底部。

你可以这样做:

 NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"instagram.igo"]; NSData *data = // set this yourself NSError *error = nil; if (! [data writeToFile:filePath options:NSDataWritingAtomic error:&error]) { // error here } self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]]; self.documentInteractionController.delegate = self; self.documentInteractionController.UTI = @"com.instagram.exclusivegram"; self.documentInteractionController.annotation = @{ @"InstagramCaption" : @"caption text here" }; const BOOL couldOpen = [self.documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:myView animated:YES]; 

设置数据,标题和视图以呈现自己。 注意UIDocumentInteractionController也是一个属性。 它应该保留在某个地方,而不仅仅是一个方法中的局部variables,因为当方法完成时,它需要存在于该范围之外。