Sudha Tiwari Sudha Tiwari - 1 month ago 9
iOS Question

Post Video on Instagram

I am working on the app where I need to post the image/video on instagram. I have successfully able to post the image on Instagram with following code:

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];

But didn't find any way to post the video on it. I checked the Instagram app and found that we can post/upload video too. It means via code It should be possible. Is anyone know about this?

Thanks in advance.


Try this code to post video on instagram it works for me hope it works for you also

first you have to save Video To Cameraroll then use this

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];