我的客户想在Instagram、Twitter、Facebook上分享一张照片.

我在Twitter和Facebook上做过,但没有在互联网上找到任何可以在Instagram上分享图片的API或任何东西.Is it possible to share image on Instagram? if yes then how?

当我查看Instagram的开发者站点时,我发现了Ruby on rails和Python库.但是没有iOS SDK的文档

根据instagram,我从instagram获得了 token .com/developer,但现在不知道下一步如何与instagram image共享.

推荐答案

我终于得到了答案.您不能直接在Instagram上发布图片.您必须使用UIDocumentInteractionController重定向您的图像.

@property (nonatomic, retain) UIDocumentInteractionController *dic;    

CGRect rect = CGRectMake(0 ,0 , 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"];

NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];
self.dic.UTI = @"com.instagram.photo";
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 {
     UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
     interactionController.delegate = interactionDelegate;
     return interactionController;
}

NOTE :一旦你重定向到instagram应用程序,你就无法返回到你的应用程序.你必须再次打开应用程序

here下载源代码

Ios相关问答推荐

彩色进度线--SWIFT

Xamarin Forms CustomPin iOS Render

快速相机放大手势不能正常工作

当S没有身体时该如何处理

Xcode -Google Mobile Ads SDK在没有AppMeasurement的情况下初始化

iOS 16.4,SwiftUI 底部工作表有时会忽略presentationDetents

不使用故事板创建 iMessage 应用程序

CoreML 不能并发(多线程)工作?

过渡动画在 iOS16 中不起作用,但在 iOS15 中起作用

iOS 如何使用 Alamofire 解析 JSON 可编码数组

SwiftUI 图像与下拉视图切换一起 skip

如何在保持纵横比的同时zoom UIView 的内容以适应目标矩形?

iOS 8 - 使用自定义演示关闭视图控制器后屏幕空白

Watchkit AppIcon - 名为AppIcon的应用图标集没有任何适用的内容

如何找出坐标之间的距离?

UITableView 背景 colored颜色 在 iPad 上总是白色

如何在react 导航中获取当前路由名称?

在 iPhone 应用程序中使用 SSL - 出口合规性

如何获取 iTunes 连接团队 ID 和团队名称?

文本未包含在 swift UI 中