且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Instagram视频iPhone Hook

更新时间:2023-01-02 21:33:11

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

I came up with the idea to allow my app to accept the instagram:// URL schema. The hook from Flipagram opened up in my app as the following:

instagram:// library?AssetPath = assets-library%3A%2F%2Fasset%2Fasset.mp4% 3Fid%3D8864C466-A45C-4C48-B76F-E3C421711E9D%26ext%3Dmp4& InstagramCaption =一些%20Preloaded%20Caption

instagram://library?AssetPath=assets-library%3A%2F%2Fasset%2Fasset.mp4%3Fid%3D8864C466-A45C-4C48-B76F-E3C421711E9D%26ext%3Dmp4&InstagramCaption=Some%20Preloaded%20Caption

未记录的iPhone挂钩,允许您自动选择资产iPhone照片滚动,并为视频预加载标题。这应该为您提供Flipagrams应用程序与Instagram共享视频时的相同用户体验。

The undocumented iPhone hook that allows you to automatically select assets from the iPhones photo roll, and preload a caption for the video. This should give you the same user experience that Flipagrams app has with sharing a video to 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已删除将标题传递给其应用的功能。现在***的解决方案就是将所需的标题复制到粘贴板上。

Update: Instagram has removed the ability to pass the caption to their app. The best solution now it to just copy the desired caption to the paste board.