Skip to content

Instantly share code, notes, and snippets.

@randhirraj3130
Created April 5, 2017 06:37
Show Gist options
  • Save randhirraj3130/00fcba80b22e6297acd740d1405c5d81 to your computer and use it in GitHub Desktop.
Save randhirraj3130/00fcba80b22e6297acd740d1405c5d81 to your computer and use it in GitHub Desktop.
instagram login in swift 3
// add the webview to your view controller add call web view delegate
// register your app into instagram
// add following code in to button action
let clientID = "aef611af2a1e4806a7de8c0aca13daac"
let redirect_uri = "http://weebook.in/"
let getAccessToken = "https://api.instagram.com/oauth/authorize/?client_id=\(clientID)&redirect_uri=\(redirect_uri)&response_type=token"
self.InstagramWebView.loadRequest(NSURLRequest(url: NSURL(string:getAccessToken as String)! as URL) as URLRequest)
// delegate function of weview
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool
{
let stringUrl : String = "\(request)"
if let range = stringUrl.range(of: "access_token="){
if(!range.isEmpty){
let array = stringUrl.components(separatedBy: "access_token=")
// print(" https://api.instagram.com/v1/users/self/media/recent/?access_token=\(array[1])")
let arrayData = "\(array[1])" as String
let myUrl : String = " https://api.instagram.com/v1/users/self/media/recent/?access_token=\(arrayData)" as String
webView.isHidden = true
LoadInstagramImageData(url: myUrl as NSString)
return false
}else{
return true
}
}
return true
}
@bapaprapu
Copy link

Hi Randhir raj,
I got "use of unresolved identifier LoadInstagramImageData " error
what can I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment