FireMonkey starts from Delphi XE2, this new framework provides many powerful components and runtime library, and the most important point is, most of the components can be used cross-platform.
XE2 -> iOS fundmental features ready.
XE3-XE5 -> Android features were appended.
XE6 -> Almost features were ready, but minor performance issue remained.
XE7 -> Everything is ready, we still need some completion for couple components.
With mobile apps development, we need to connect the web server from time to time. Indy components play as a proper role for Delphi and C++ Builder, but the SSL feature is not perfect yet.
Hence, we still need TWebBrowser for user to interact with website, if the feedback or redirect path contains HTTPS URL, e.g., Facebook login, Google+ login.
However, there is no interfaces provided by TWebBrowser for retrieving the content of the page.
A->B, B->C, C->DIt's said in some movies, "Genius can get A to D without intermediate path, other cannot", I am not genius, so I have to find out A->B, B->C, C->D to achieve A->D.
The following is my thought:
A->D, A is the TWebBrowser, D is retrieveing content.
TWebBrowser can get the URL, which the browser wish to navigate.
So, the workaround is:
1. waiting for the target URL we want to get the content, e.g. the Google+ login result page.
http://www.moveinpocket.com/demo/GoogleLogin_API/index2.php (login page)
https://www.googleapis.com/oauth2/v1/userinfo?access_token= (login success page, the user information will be sent back with JSON format.)
2. if the login success page is done, the onDidFinishLoad event handler will handle the JSON Page:
self.WebBrowser1.URL) = 1) then begin
js := 'var markup = document.documentElement.innerText;' + #13 + #10
+ 'var newURL = "http://126.96.36.199/" + markup;' + #13 + #10 +
'window.location = newURL;';
4. Let onShouldStartLoadURL of Browser to get "http://188.8.131.52/" url, then we got the content in Delphi!
if (Pos('http://184.108.40.206/', URL) = 1) then beginI had search some work around with the following key words in Google, Stackoverflow, and it's pity that there is no any solution yet:
self.WebBrowser1.Height := 1;
jsonStr := URL;
jsonStr := TIdURI.URLDecode(jsonStr, IndyTextEncoding_UTF8);
self.Memo1.Lines.Text := jsonStr;
self.TabControl1.ActiveTab := self.TabItemResult;
Delphi, FireMonkey, WebBrowser, get HTML, get JSON, get Content.
So, this work around might be the only way to get content from TWebBrowser, if you need the sample project, please download from here.
Best Regard, and Enjoy your Delphi.