2014-04-02 27 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

相關問題