Skip to content

Instantly share code, notes, and snippets.

@kwylez
Created September 24, 2010 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwylez/595379 to your computer and use it in GitHub Desktop.
Save kwylez/595379 to your computer and use it in GitHub Desktop.
- (void)webViewDidFinishLoad:(UIWebView *)webView {
/**
* Since there are a lot redirects then UIWebview delegate methods are called ALOT.
* Therefore I just want to check and make sure that I am only getting the value when the url has my hostname in it
*/
NSRange rangeRound = [[[webView.request URL] absoluteString] rangeOfString:@"corywiles"];
if (rangeRound.length) {
NSString *authToken = [[webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('token').innerHTML"]
stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(@"authToken: %@", authToken);
} else {
NSLog(@"no auth token");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment