I need to share the image using Instagram. I have created CLIENT ID and CLIENT SECRET using this. I have searched in stack overflow but i dint find any useful links. Can anybody help me to solve this problem.
Asked
Active
Viewed 480 times
1
-
Try below link this might be helpful for you http://stackoverflow.com/questions/18242610/uploading-photos-to-instagram-via-your-own-ios-app – Sukeshj Apr 02 '14 at 07:15
1 Answers
2
Yes You can post image on instagram as below code
-(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];
}
}
Upload image on instagram:

Kirit Modi
- 23,155
- 15
- 89
- 112
-
Updated my code with some of yours and it worked, but the problem is that it takes me to my instagram Timeline not to the add photo view, is registering MUST? to redirect to posting image? i Also want to know if registering my application with Instagram is must also even during developing phase ? – Mohammed almoalla Apr 04 '14 at 20:26
-
' [[UIApplication sharedApplication] openURL:instagramURL];' This was extra removing it solved the problem – Mohammed almoalla Apr 04 '14 at 20:55
-
i do extactly the same but got error `*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType URL]: unrecognized selector sent to instance 0x147d67c0' *** First throw call stack: (0x2698cf87 0x340ebc77 0x2699237d 0x26990259 0x268c1d68 0x2a450e89 0x275e3065 0x27688277 0x892eb5 0x88d3fd 0x89455b 0x895885 0x347c9e25 0x347c9b78) libc++abi.dylib: terminating with uncaught exception of type NSException` – TomSawyer Nov 07 '14 at 15:37