从我的iOS应用程序分享照片到Instagram

我一直在寻找一种方式来从我正在开发的iOS应用程序发布照片到Instagram。 但看到一些链接,似乎是他们不支持使用他们的API写访问。 所以,

  1. 是否有可能通过一些API或Instagram API从iOS分享照片到Instagram?
  2. 如果可能的话,任何人都可以给我build议一个教程或文档来做到这一点?

他们的api说这个…

“目前,通过API上传是不可能的,我们有意识地select不添加这个,原因如下:

Instagram是关于你在旅途中的生活 – 我们希望鼓励在应用程序内的照片。 但是,将来我们可能会根据具体情况给予单个应用的白名单访问权限。 我们想打击垃圾邮件和低质量的照片。 一旦我们允许从其他来源上传,就很难控制进入Instagram生态系统的内容。 所有这一切,我们正在努力确保用户在我们的平台上获得一致的,高质量的体验。“

这就是为什么我正在寻找更好的build议。

在此先感谢您的帮助。

请尝试在设备中的代码….共享不起作用在模拟器

它将图像从应用程序保存到文件目录,它将共享相同的图像到instagram。

对于分享我只会采取.igo格式

-(void)shareInInstagram { NSData *imageData = UIImagePNGRepresentation(imge); //convert image into .png format. NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it NSString *documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"insta.igo"]]; //add our image to the path [fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; //finally save the path (image) NSLog(@"image saved"); CGRect rect = CGRectMake(0 ,0 , 0, 0); UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIGraphicsEndImageContext(); NSString *fileNameToSave = [NSString stringWithFormat:@"Documents/insta.igo"]; NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:fileNameToSave]; NSLog(@"jpg path %@",jpgPath); NSString *newJpgPath = [NSString stringWithFormat:@"file://%@",jpgPath]; //[[NSString alloc] initWithFormat:@"file://%@", jpgPath] ]; NSLog(@"with File path %@",newJpgPath); NSURL *igImageHookFile = [[NSURL alloc] initFileURLWithPath:newJpgPath]; NSLog(@"url Path %@",igImageHookFile); self.dic.UTI = @"com.instagram.exclusivegram"; self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self]; self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile]; [self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ]; } - (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate { NSLog(@"file url %@",fileURL); UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL]; interactionController.delegate = interactionDelegate; return interactionController; }