Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

ios - Posting video on instagram using hooks

I want my app to be able to upload videos to instagram.

Instagram IPhone Hooks gives information how to use the iphone hooks to upload a photo to instagram. My question is if anyone has any experience on how to accomplish the same but for a video?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...