Posting video on instagram using hooks

Instagram’s API doesn’t directly support uploading anything from 3rd party applications. Therefore you have to do some ugly user experience compromises when providing the functionality to your users.

First, Prepare the video you want to upload to Instagram and store the path to it somewhere

Second, Save it to the user’s Camera Roll:

if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(filePath)) {
    UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
}

Third, now that the video is saved, tell the user that in order to upload the video to their Instagram, they must select it from their camera roll after clicking the upload button.

The upload button would simply do the following:

NSURL *instagramURL = [NSURL URLWithString:@"instagram://camera"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    [[UIApplication sharedApplication] openURL:instagramURL];
}

It’s very silly that the Instagram API doesn’t support immediate media selection through any of the API endpoints for upload purposes, but as it stands right now, this is the only way.

Leave a Comment