To follow, we only need client_id
First, create client_id by registering your application on Instagram
and open this 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 a 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"];
task.recieveAsyncResponse = self;
}
return YES;
}
shouldStartLoadWithRequest
, Uri, , URL =. , , , .