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

 Resolve 发布于 2023-02-13 17:59

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

    是否可以通过某些API或Instagram API从iOS分享照片到Instagram?

    如果可能,任何人都可以建议我做一个教程或文档吗?

他们的api说这个......

"目前,无法通过API上传.我们有意识地选择不添加此内容,原因如下:

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

这就是为什么我在寻找更好的建议.

在此先感谢您的帮助.

1 个回答
  • 请在设备中尝试此代码....共享在模拟器中不起作用

    它会将图像从应用程序保存到文档目录,它将共享相同的图像到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;
    }
    

    2023-02-13 18:02 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有