Search code examples
iphoneobjective-cfacebookuiwebviewnsurl

iPhone/Objective-C - Retrieving echoed PHP text from UIWebView


I have a website that returns an access_token (i.e. Facebook).

The redirect_uri has been changed to point to a PHP file on my web server. The PHP code simply echoes the users offline facebook access_token to the page.

What would be the best way to grab this access_token so I can store it within NSUserDefaults?

I'm assuming I'd need to use UIWebView's:

[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];

In some way shape or form?

Any help would be greatly appreciated.


Solution

  • Don't use a webview! It consumes resources and is slow for that purpose.

    Make use of a Framework like ASIHttpRequest to fire a http get request or use Apple's NSURLConnection. You may even consider using https to bring in some security.