当前位置:  开发笔记 > 编程语言 > 正文

Instagram挂钩预选媒体问题

如何解决《Instagram挂钩预选媒体问题》经验,为你挑选了1个好方法。

这是我的代码.该文件已正确添加到照片库,但在Instagram应用程序中此网址 - > instagram://library?AssetPath=assets-library%3A%2F%2Fasset%2Fasset.mp4%3Fid=5EDBD113-FF57-476B-AABB-6A59F31170B5&ext=mp4&InstagramCaption=my%caption不打开最后一个视频.

- (void)loadCameraRollAssetToInstagram:(NSURL*)assetsLibraryURL andMessage:(NSString*)message
{
    NSString *escapedString   = [self urlencodedString:assetsLibraryURL.absoluteString];
    NSString *escapedCaption  = [self urlencodedString:message];
    NSURL *instagramURL       = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@", escapedString, escapedCaption]];

    NSLog(@"instagramURL ==> %@",instagramURL);

    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
        NSLog(@"Open Instagram!!");
        [[UIApplication sharedApplication] openURL:instagramURL];
    } else {
        NSLog(@"Cant open Instagram!!");
        [[[UIAlertView alloc] initWithTitle:@"Instagram" message:@"App not installed" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil] show];
    }
}

- (NSString*)urlencodedString:(NSString *)message
{
    return [message stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
}

- (void)saveToCameraRoll:(NSURL *)srcURL withCurrentAction:(NSString *)action
{
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    ALAssetsLibraryWriteVideoCompletionBlock videoWriteCompletionBlock = ^(NSURL *newURL, NSError *error) {

        if (error) {
            NSLog( @"Error writing image with metadata to Photo Library: %@", error );
            [[[UIAlertView alloc] initWithTitle:@"Facebook" message:@"Pal - Currently we can't process your video. Please try again in few moments" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Sign In", nil] show];

        } else {
            NSLog( @"Wrote image with metadata to Photo Library: %@", newURL.absoluteString);
            if ([action isEqualToString:@"instagram"])
                [self loadCameraRollAssetToInstagram:newURL andMessage:@"My caption"]; //Can be any text?
        }
    };

    if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:srcURL])
    {
        [library writeVideoAtPathToSavedPhotosAlbum:srcURL completionBlock:videoWriteCompletionBlock];
    }
}

在此输入图像描述

一些非常奇怪的事情是完美的,直到我转向卸载然后安装Instagram.不知道这是否有事可做



1> borisgolovne..:

instagram://library?AssetPath=\(assetsLibraryUrl) 前一段时间停止了工作.Instagram开发人员可能已迁移到Photos框架,不再使用AssetsLibrary.

有了这个假设,我试过几个其他的参数名称,发现instagram://library?LocalIdentifier=\(localID)这里localIdlocalIdentifier你的PHAsset作品现在.

这仍然没有文档,所以它可以在Instagram的任何未来版本中破解.


将视频保存到图库后如何获取此LocalIdentifier?
推荐阅读
黄晓敏3023
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有