B4J Question WebView not engime crome, edge ,,,,

ivanomonti

Expert
Licensed User
Longtime User
when I use some web api whastapp the browser requires me a web engine as image, how can I get rid of this problem, I better send the request by opening the command from a shell command

possible to have help

Cattura.PNG
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can change the user agent:
B4X:
Dim jo As JavaObject = WebView1
jo = jo.RunMethod("getEngine", Null)
jo.RunMethod("setUserAgent", Array("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"))
'check:
WebView1.LoadUrl("https://www.whatismybrowser.com/")
It is impossible to say whether it will work with this site.
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
in fact it loads to 90% and then returns the previous page ,,, I can not make the classic login page of whastapp

B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

' https://faq.whatsapp.com/en/general/26000030

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private link As String = "https://wa.me/$Phone?text=$Text"
    Private Button1 As Button
    Private TextField1 As TextField
    Private TextField2 As TextField
    Private WebView1 As WebView
    Private Button2 As Button
    Private Button3 As Button
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
    Jweb(WebView1,"https://web.whatsapp.com/")
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Button1_Click
    link = link.Replace("$Phone",TextField1.Text).Replace("$Text",TextField2.Text)
    Jweb(WebView1,link)
End Sub

Sub Button3_Click
    Jweb(WebView1,"http://www.enre.it/")
End Sub
    
Sub Button2_Click
    Jweb(WebView1,"https://web.whatsapp.com/")
End Sub

Sub Jweb(wv As WebView, url As String)
    Dim jo As JavaObject = wv
    jo = jo.RunMethod("getEngine", Null)
    jo.RunMethod("setUserAgent", Array("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"))
    'check:
    wv.LoadUrl(url)
End Sub
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
I refresh the memory of how I can send the request to external crome or similar from b4j!
 
Upvote 0
Top