关闭

Instagram分享

标签: iosinstagram视频
479人阅读 评论(0) 收藏 举报
分类:

分享图片

The answer is that it is not pulling the video from the camera roll at all, it might just look like it is.

Documentation here: http://instagram.com/developer/mobile-sharing/iphone-hooks/

The relevant bit is the bottom section "Document Interaction".

You would do this by doing something like this:

NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"instagram.igo"];
NSData *data = // set this yourself

NSError *error = nil;
if (! [data writeToFile:filePath options:NSDataWritingAtomic error:&error])
{
    // error here
}

self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
self.documentInteractionController.delegate = self;
self.documentInteractionController.UTI = @"com.instagram.exclusivegram";
self.documentInteractionController.annotation = @{ @"InstagramCaption" : @"caption text here" };
const BOOL couldOpen = [self.documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:myView animated:YES];

Set the data, the caption, and the view to present from yourself. Notice the UIDocumentInteractionController is also a property. It should be retained somewhere and not just a local variable in a method because it needs to exist outside of that scope when the method completes.



分享视频

 


- (void)shareVideoWithInstagram {

[assetsLibrary writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:videoPath] completionBlock:^(NSURL *assetURL, NSError *error) {

NSString *caption = @"Your caption";

    NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",

                                                [[assetURL absoluteString] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]],

                                                [caption stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]]]

                           ];

    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {

        [[UIApplication sharedApplication] openURL:instagramURL];

    }

   

}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:5385次
    • 积分:125
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:16篇
    • 译文:0篇
    • 评论:0条
    文章分类