2013-03-01 192 views
5

我想分享文本/照片/視頻到Instagram。我正在尋找這個很長一段時間,但我沒有得到任何適當的文件。如果有人知道關於instagram的份額,請告訴我。如何在ios中分享文本/照片/視頻到Instagram

+0

使用下面的代碼,你可以張貼照片,但是這個代碼將打開相機,然後點擊照片會從你的應用Instagram的上傳。 NSURL * instagramURL = [NSURL URLWithString:@「instagram:// location?id = 1」];如果([[UIApplication sharedApplication] canOpenURL:instagramURL]){ [[UIApplication sharedApplication] openURL:instagramURL]; } – 2015-10-21 17:01:41

回答

0

請嘗試下面的代碼。

@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]]; 
// NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", screenshot]]; 

self.dic.UTI = @"com.instagram.photo"; 
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self]; 
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile]; 
self.dic.annotation = [NSDictionary dictionaryWithObject:@"Here Give what you want to share" forKey:@"InstagramCaption"]; 
[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; 
} 

它適用於我。希望它可以幫助你。

2

Instagram Media Endpoints

此時,通過API上傳是不可能的。我們有意識地選擇不添加這個,原因如下:

Instagram是關於你在旅途中的生活 - 我們希望在應用內鼓勵照片 。但是,未來我們可能會根據具體情況向白名單 訪問各個應用。

我們想要打擊垃圾郵件&低質量的照片。一旦我們允許從其他來源上傳 ,就很難控制進入到Instagram生態系統的內容。所有這一切,我們正在努力找到 ,確保用戶在我們的 平臺上擁有一致的高質量體驗。

也許你可以試試鉤:http://instagram.com/developer/iphone-hooks/https://instagram.com/developer/mobile-sharing/android-intents/

相關問題