Integrating Instagram SDK in your iOS apps

Click here to find out how to schedule an event in less than 2minutes and save time !!!!
Lets get straight to the point. Unlike facebook, Instagram doesn’t have an SDK specifically tailored for iOS. We need to use https requests to authorize the user. This is pretty easy if your doing it on the web. But if you are going to do it using iOS, its not straight forward. First things first ,
a. Goto Instagram and register yourself and your client.
b. You would need the following:
CLIENT ID df2esdfasdfdsfasdfadsfadsfadsf34c27
CLIENT SECRET 357dsasdfadsfasdfadsfasdfb96b0313
WEBSITE URL http://localhost:8888/MAMP/
REDIRECT URI http://localhost:8888/MAMP/
c. I don’t want to elaborate much on this topic. Its all specified in the Instagram website.
d. Lets get to the iOS part now. You would need to UIWebview to get the job done.
[sourcecode language=”objc”]
@interface viewController : UIViewController<UIWebViewDelegate> // need this delegate here
[sourcecode language=”objc”]
– (void)viewDidLoad
[super viewDidLoad];
// create a webview
UIWebView* mywebview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
NSString *fullURL = @"";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[mywebview loadRequest:requestObj];
mywebview.delegate = self;
[self.view addSubview:mywebview];
If you run the above code, you will get the authorization page as shown below:
Next lets get to the crux of this post. Getting the access code, which what we want for getting the instagram photos.
[sourcecode language=”objc”]
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSString* urlString = [[request URL] absoluteString];
NSURL *Url = [request URL];
NSArray *UrlParts = [Url pathComponents];
// do any of the following here
if ([[UrlParts objectAtIndex:(1)] isEqualToString:@"MAMP"]) {
//if ([urlString hasPrefix: @"localhost"]) {
NSRange tokenParam = [urlString rangeOfString: @"access_token="];
if (tokenParam.location != NSNotFound) {
NSString* token = [urlString substringFromIndex: NSMaxRange(tokenParam)];
// If there are more args, don’t include them in the token:
NSRange endRange = [token rangeOfString: @"&"];
if (endRange.location != NSNotFound)
token = [token substringToIndex: endRange.location];
NSLog(@"access token %@", token);
if ([token length] > 0 ) {
// display the photos here
instagramTableViewController *iController = [[instagramPhotosTableViewController alloc] initWithStyle:UITableViewStylePlain];
NSString* redirectUrl = [[NSString alloc] initWithFormat:@"", token];
// use delegate if you want
//[self.delegate instagramLoginSucceededWithToken: token];
else {
// Handle the access rejected case here.
NSLog(@"rejected case, user denied request");
return NO;
return YES;
The above code should be able to get you started.

6 Replies to “Integrating Instagram SDK in your iOS apps”

  1. Sorry, it’s been late but i need your help. I have register my app for using secure api to get the feature like,comment, relationship etc. But can’t understand how much time it needs to review app. Please help.

Leave a Reply

Your email address will not be published.