将应用程序与Instagram集成..如何做到这一点请提前帮助谢谢 这是我试过的代码
NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"Image.ig"];
UIImage *image = [UIImage imageNamed:@"instagram.jpeg"];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedImagePath atomically:YES];
NSURL *imageUrl = [NSURL fileURLWithPath:savedImagePath];
NSLog(@"%@",imageUrl);
UIDocumentInteractionController *docController = [[UIDocumentInteractionController alloc] init];
docController.delegate = self;
docController.UTI = @"com.instagram.photo";
docController.URL = imageUrl;
[docController setURL:imageUrl];
[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
答案 0 :(得分:4)
现在在iOS中使用Instagram API要简单得多。查看此新版SDK http://github.com/shyambhat/InstagramKit
答案 1 :(得分:0)
您应该查看InstagramShareiOS和How to share an image on Instagram in iOS?
请注意,您实际上无法通过API发布到Instagram,您只能检查并启动Instagram应用程序并准备好发布图像。 Instagram没有打开他们发布的API,我怀疑他们会,因为他们想鼓励用户(1)使用他们的应用程序和(2)使用他们的过滤器,自动调整和其他有助于Instagram的功能用户体验。
此外,一旦你离开你的应用程序并启动Instagram,就没有自动返回方式,FWIW。