您的位置:首页 > 移动开发 > IOS开发

Instagram分享

2015-11-20 11:43 323 查看
分享图片

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

    }

   

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios instagram 视频