2014-04-02 40 views
1

我需要使用Instagram共享图像。我使用this创建了CLIENT ID和CLIENT SECRET。我已经在堆栈溢出搜索,但我dint找到任何有用的链接。任何人都可以帮助我解决这个问题。我们可以使用iOS应用程序在Instagram发布图像

+0

尝试下面的链接,这可能对你 HTTP是有帮助://stackoverflow.com/questions/18242610/uploading-photos-to-instagram-via-your-own-ios-app – Sukeshj

回答

2

是的,你可以张贴在Instagram的图片如下代码

-(IBAction)uploadimage:(UIButton*)sender 
{ 

    NSURL *instagramURL = [NSURL URLWithString:@"instagram://"]; 

    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) 
    { 

     CGSize size=CGSizeMake(612, 612); 

     UIImage *TajImage = [UIImage imageNamed:@"gujarat.jpg"]; 

     UIImage *image = [self scale:TajImage toSize:size]; 

     NSString *jpgPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"instagram.igo"]; 


     [UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES]; 

     CGRect rect = CGRectMake(0 ,0 , 0, 0); 

     NSURL *fileURL = [NSURL fileURLWithPath:jpgPath]; 

     self.docFile = [UIDocumentInteractionController interactionControllerWithURL:fileURL]; 

     self.docFile.delegate = self; 

     [self.docFile setUTI:@"com.instagram.exclusivegram"]; 

     [self.docFile setAnnotation:@{@"InstagramCaption" : @"Gujarti Lion,Girnar,India"}]; 

     [ self.docFile presentOpenInMenuFromRect:rect inView:self.view animated:YES]; 

     [[UIApplication sharedApplication] openURL:instagramURL]; 

    } 
} 

上传图像上的Instagram:

enter image description here

+0

更新了我的一些代码,它的工作原理,但问题是,它使我到我的Instagram时间轴不添加照片视图,注册必须?重定向到发布图片?我也想知道如果在Instagram上注册我的应用程序也必须在开发阶段? –

+0

'[[UIApplication sharedApplication] openURL:instagramURL];'这是额外的删除它解决了问题 –

+0

我做的extactly一样,但得到错误***终止应用程序,由于未捕获的异常'NSInvalidArgumentException',原因:' - [__ NSCFType URL]:无法识别的选择发送到实例0x147d67c0' ** *第一次调用堆栈: (0x2698cf87 0x340ebc77 0x2699237d 0x26990259 0x268c1d68 0x2a450e89 0x275e3065 0x27688277 0x892eb5 0x88d3fd 0x89455b 0x895885 0x347c9e25 0x347c9b78) libC++ abi.dylib:以NSException类型的未捕获异常终止 – TomSawyer

相关问题