Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Login Instagram API iOS

I'm developing an application for iOS with the authentication, using Instagram API.

My code for authentication works good:

NSString *fullURL = [NSString stringWithFormat:@"https://instagram.com/oauth/authorize/?client_id=%@&redirect_uri=%@&response_type=code",KCLIENTID,kREDIRECTURI];
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

instagramConnectWebView = [[UIWebView alloc] initWithFrame:self.view.bounds]; 
instagramConnectWebView.delegate = self;
[instagramConnectWebView loadRequest:request];

When the request is sent, my webView shows the standard Instagram login interface, where user has to insert username and password to login. If login succeed, app is redirected to my redirection-url, where i get the code and the token of this user.

My question is really simple, is there a way to customize standard interface of Instagram login? I'd like to insert in my app two simple UITextField (One for username and one for the password) and when user clicks on my UIButton login, application should send (POST or GET?) username and password to Instagram, and return response (Login success or not).

I hope i explained myself.

Thanks.

like image 832
lubilis Avatar asked Apr 12 '14 12:04

lubilis


1 Answers

You can make this by using javascript. by loading a web view in background :

You need to access the text field of that web view and pass value of your custom UItextfields and after that you can call webView's "Submit" button's Onclick event.

NSString *javaScript = @"document.getElementById('id_username').value = 'tfusername'";
NSString *javaScript2 = @"document.getElementById('id_password').value = 'tfpassword'";

to evaluate each script you can call: [webView stringByEvaluatingJavaScriptFromString:javaScript];

You can also call script to press login button. This same thing work for me. May be this will help you.

like image 167
Esha Avatar answered Nov 03 '22 04:11

Esha