Created
April 5, 2017 06:37
-
-
Save randhirraj3130/00fcba80b22e6297acd740d1405c5d81 to your computer and use it in GitHub Desktop.
instagram login in swift 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Randhir raj,
I got "use of unresolved identifier LoadInstagramImageData " error
what can I do?