B4J Question jOkHttpUtils2 Banano

ddefrain

Member
Licensed User
Longtime User
Hello; is it posibble to apply the jOkHttpUtils2 in BaNano?

...or how Do I Get the following? 'cause if I use that one I get The following error
B4X:
scripts/app1662506135262.js:28984 Uncaught SyntaxError: Unexpected token ';'

B4X:
PlaceToLatLon("San Diego, CA","National City, CA")

B4X:
Sub PlaceToLatLon(destino As String, origen As String) As ResumableSub
    Dim  resmin As String
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download2("https://maps.googleapis.com/maps/api/distancematrix/json", Array As String("key", APIKEY, "destinations", destino, "origins", origen, "departure_time", "now"))
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Dim jp As JSONParser
        jp.Initialize(j.GetString)
        Dim m As Map = jp.NextObject
        If m.Get("status") = "OK" Then
            Dim results As List = m.Get("rows")
            If results.Size > 0 Then
                Dim rows As List = results
                For Each colrows As Map In rows
                    Dim elements As List = colrows.Get("elements")
                    For Each colelements As Map In elements
                        Dim duration As Map = colelements.Get("duration")
                        Log(duration.Get("value"))
                        Try
                            Dim duration_in_traffic As Map = colelements.Get("duration_in_traffic")
                            Dim text As String = duration_in_traffic.Get("text")
                            resmin = text
                        Catch
                            Log(LastException)
                        End Try
                    Next
                Next
            End If
        End If
    Else
        Log("Error!")
        resmin = m.Get("status")
    End If
    j.Release
    Return resmin
End Sub
 

ddefrain

Member
Licensed User
Longtime User
Hello; is it posibble to apply the jOkHttpUtils2 in BaNano?

...or how Do I Get the following? 'cause if I use that one I get The following error
B4X:
scripts/app1662506135262.js:28984 Uncaught SyntaxError: Unexpected token ';'

B4X:
PlaceToLatLon("San Diego, CA","National City, CA")

B4X:
Sub PlaceToLatLon(destino As String, origen As String) As ResumableSub
    Dim  resmin As String
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download2("https://maps.googleapis.com/maps/api/distancematrix/json", Array As String("key", APIKEY, "destinations", destino, "origins", origen, "departure_time", "now"))
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Dim jp As JSONParser
        jp.Initialize(j.GetString)
        Dim m As Map = jp.NextObject
        If m.Get("status") = "OK" Then
            Dim results As List = m.Get("rows")
            If results.Size > 0 Then
                Dim rows As List = results
                For Each colrows As Map In rows
                    Dim elements As List = colrows.Get("elements")
                    For Each colelements As Map In elements
                        Dim duration As Map = colelements.Get("duration")
                        Log(duration.Get("value"))
                        Try
                            Dim duration_in_traffic As Map = colelements.Get("duration_in_traffic")
                            Dim text As String = duration_in_traffic.Get("text")
                            resmin = text
                        Catch
                            Log(LastException)
                        End Try
                    Next
                Next
            End If
        End If
    Else
        Log("Error!")
        resmin = m.Get("status")
    End If
    j.Release
    Return resmin
End Sub
I open the script file and in that line says /* httpjob NOT SUPPORTED */

How do I Read an external URL through BaNano?

Thank's in advance!
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Hello; is it posibble to apply the jOkHttpUtils2 in BaNano?

...or how Do I Get the following? 'cause if I use that one I get The following error
B4X:
scripts/app1662506135262.js:28984 Uncaught SyntaxError: Unexpected token ';'

B4X:
PlaceToLatLon("San Diego, CA","National City, CA")

B4X:
Sub PlaceToLatLon(destino As String, origen As String) As ResumableSub
    Dim  resmin As String
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download2("https://maps.googleapis.com/maps/api/distancematrix/json", Array As String("key", APIKEY, "destinations", destino, "origins", origen, "departure_time", "now"))
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Dim jp As JSONParser
        jp.Initialize(j.GetString)
        Dim m As Map = jp.NextObject
        If m.Get("status") = "OK" Then
            Dim results As List = m.Get("rows")
            If results.Size > 0 Then
                Dim rows As List = results
                For Each colrows As Map In rows
                    Dim elements As List = colrows.Get("elements")
                    For Each colelements As Map In elements
                        Dim duration As Map = colelements.Get("duration")
                        Log(duration.Get("value"))
                        Try
                            Dim duration_in_traffic As Map = colelements.Get("duration_in_traffic")
                            Dim text As String = duration_in_traffic.Get("text")
                            resmin = text
                        Catch
                            Log(LastException)
                        End Try
                    Next
                Next
            End If
        End If
    Else
        Log("Error!")
        resmin = m.Get("status")
    End If
    j.Release
    Return resmin
End Sub
I have used the distance matrix API on this project, https://www.b4x.com/android/forum/t...p-for-travel-subsistence-logs.141713/#content

For client side use BANanoFetch

All the best..
 
Upvote 0
Top