To follow we only need client_id
First of all create a client_id by registering your app on Instagram
and open given Url in webView.
NSString *urlAddress =[NSString stringWithFormat:@"https://instagram.com/oauth/authorize/?client_id=%@&redirect_uri=http://appbellfitness.com/&response_type=token&scope=likes+comments+relationships",client_id];
NSURL *nsurl=[NSURL URLWithString:urlAddress];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview loadRequest:nsrequest];
webview.delegate = self;
And add WebView delegate to it.
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString *orignalUrl =[request.URL absoluteString];
if ([orignalUrl hasPrefix:CALLBACKURL])
{
NSArray* parts = [orignalUrl componentsSeparatedByString: @"="];
request_token = [parts objectAtIndex: 1];
NSString *myurl =[NSString stringWithFormat:@"https://api.instagram.com/v1/users/25025320/relationship?access_token=%@",request_token];
NSString *action=@"action=follow";
BsyncTask *task = [[BsyncTask alloc]init];
[task asynchronousPost:action url:myurl callerName:@"followTask"];//post this as you like
task.recieveAsyncResponse = self;
}
return YES;
}
shouldStartLoadWithRequest
I check it starts with my redirect Uri then I get the access token by seperating the url on the basis of = sign. and then i post it using my class you can post it as you like and get response.