在Instagram上发布视频

Sud*_*ari 7 objective-c ios instagram

我正在开发应用程序,我需要在Instagram上发布图像/视频.我已经成功地使用以下代码在Instagram上发布图像:

        NSString* filename = [NSString stringWithFormat:@"myimage.igo"];
        NSString* savePath = [imagesPath stringByAppendingPathComponent:filename];
        [UIImagePNGRepresentation(myImage) writeToFile:savePath atomically:YES];
        NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
        if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
        {
            self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
            self.documentInteractionController.UTI = @"com.instagram.image";
            self.documentInteractionController.delegate = self;
            [self.documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
        }
Run Code Online (Sandbox Code Playgroud)

但没有找到任何方式发布视频.我检查了Instagram应用程序,发现我们也可以发布/上传视频.它意味着通过代码它应该是可能的.有人知道吗?

提前致谢.

Ash*_*kar 2

尝试使用此代码在 Instagram 上发布视频,它对我有用,希望对您也有用

首先你必须将视频保存到Cameraroll然后使用它

NSString *strURL = [NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",yourfilepath,yourCaption];
NSString* webStringURL = [strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL* instagramURL = [NSURL URLWithString:webStringURL];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
[[UIApplication sharedApplication] openURL:instagramURL];
}
Run Code Online (Sandbox Code Playgroud)