Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 545
Sudha Tiwari Avatar asked Mar 31 '14 08:03

Sudha Tiwari


1 Answers

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];
}
like image 98
Ashish Thakkar Avatar answered Sep 28 '22 21:09

Ashish Thakkar