Italian Invio info 'User Agent'

andaghit

New Member
Licensed User
Longtime User
Buon giorno,
Ho fatto un app che fa semplici richieste ad un sito ospitato in netsons.org

Sub ExecuteRemoteQuery(sqlquery As String, JobName As String)


Dim job As HttpJob
job.Initialize(JobName, Me)
job.Download("http://miosito.netsons.org/mioscript.php?comando=test)


End Sub

e la cosa ha funzionato dal 2022 fino a pochi giorni fa,
quando il server mi risponde ad ogni tipo di richiesta:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
<p>Additionally, a 403 Forbidden
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

interpellata l'assistenza mi dicono che viene 'bloccato' perchè nella richiesta non viene trovato un 'user agent'

Al di là che evidentemente avranno cambiato qualcosa per cui prima andava ora non più, ma , eventualmente, come posso
passare il dato 'user agent' ?

Vedo che Download2 prevede di passare variabili ma non saprei come fare.

Qualcuno può aiutarmi?
Grazie
Andrea
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Dim j As HttpJob
j.Initialize("job name", Me)
j.Download(<link>) 'it can also be PostString or any of the other methods
j.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0")
 

andaghit

New Member
Licensed User
Longtime User
Grazie Star-Dust
lo avevo appena provato ma non da risultati diversi.
Mi sa che la storia del mancato User-Agent sia una risposta buttata là dall'assistenza ...
grazie comunque
 

Star-Dust

Expert
Licensed User
Longtime User
verifica se devi usare https://
 

Sagenut

Expert
Licensed User
Longtime User
Prova anche a cambiare User Agent (anche se forse non sarà la soluzione)
Questo dovrebbe essere abbastanza recente
B4X:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0
 

Filippo

Expert
Licensed User
Longtime User
Buon giorno,
Ho fatto un app che fa semplici richieste ad un sito ospitato in netsons.org

Sub ExecuteRemoteQuery(sqlquery As String, JobName As String)


Dim job As HttpJob
job.Initialize(JobName, Me)
job.Download("http://miosito.netsons.org/mioscript.php?comando=test)


End Sub

e la cosa ha funzionato dal 2022 fino a pochi giorni fa,
quando il server mi risponde ad ogni tipo di richiesta:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
<p>Additionally, a 403 Forbidden
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

interpellata l'assistenza mi dicono che viene 'bloccato' perchè nella richiesta non viene trovato un 'user agent'

Al di là che evidentemente avranno cambiato qualcosa per cui prima andava ora non più, ma , eventualmente, come posso
passare il dato 'user agent' ?

Vedo che Download2 prevede di passare variabili ma non saprei come fare.

Qualcuno può aiutarmi?
Grazie
Andrea
Questo problema l'ho avuto anche io. Ho provato tutti gli User-Agent possibile e immaginari senza alcun risultuato positivo.

Puoi ho provato con la libreria WebViewExtras e ora funziona tutto senza alcun problema.

B4X:
Private WebViewExtras1 As WebViewExtras
Private Wv As WebView
    
Sub ExecuteRemoteQuery(sqlquery As String, JobName As String)
    getWebSeiteAlsString("http://miosito.netsons.org/mioscript.php?comando=test")
End Sub

Sub getWebSeiteAlsString(sURL As String)
    
    Wv.Initialize("Wv")
    
    WebViewExtras1.addJavascriptInterface(Wv, "B4A")

    Wv.LoadUrl(sURL)

End Sub

Private Sub Wv_PageFinished (Url As String)
    '   Now that the web page has loaded we can get the page content as a String
  
    Dim Javascript As String
    Javascript="B4A.CallSub('Process_HTML', false, document.documentElement.outerHTML)"
  

    'Log("PageFinished: "&Javascript)
    WebViewExtras1.executeJavascript(Wv, Javascript)
End Sub

Private Sub Process_HTML(Html As String) 'ignore
    '   This is the Sub that we'll get the web page to send it's HTML content to
 
     'Log("ProcessHTML: " & Html)
    ParseWebSite(Html)
    
    ProgressDialogHide
End Sub

Private Sub ParseWebSite(Website As String)
'il tuo codice
End Sub
 
Top