api call not working on android
Posted: Sat Jan 04, 2020 1:27 am
Evening livecoders
Well I'm here again, its heading towards 1 in the morning and I'm stumped again. As ever any help would be very much appreciated:
I am making an api call to google distance matrix, it works fine on the desktop, but not on android. As far as I can tell nothing is returned??!!!!
The code is-
command check_distance_to_school_only
if the environment is "mobile" then
set the defaultFolder to specialFolderPath("external documents")
end if
put URL ("file:saved_currentlocation.txt") into tphone_location
put URL ("file:saved_school_location.txt") into tschool_location
put URL ("file:saved_school_geof_size.txt") into tgeof
put "https://maps.googleapis.com/maps/api/di ... n?origins=" & tphone_location & "&destinations=" & tschool_location & "&mode=walking&key=AIzaSyCF13NFbjMMz7zETlkSoMpuIdVjYr8a9Ew" into tlocation_request
put URL (tlocation_request) into tlocation_response --NOTE just put brackets in to check
put jsontoarray(tlocation_response) into tdistance_Array
put tdistance_Array["rows"]["1"]["elements"]["1"]["distance"]["value"] into tdistance_from_school
put tdistance_from_school into URL ("file:saved_current_distance_from_school.txt")
if tdistance_from_school <= tgeof then
put "in school" into URL ("file:saved_current_location_type.txt")
else
put "out of school" into URL ("file:saved_current_location_type.txt")
end if
end check_distance_to_school_only
Thanks again
Paul
Well I'm here again, its heading towards 1 in the morning and I'm stumped again. As ever any help would be very much appreciated:
I am making an api call to google distance matrix, it works fine on the desktop, but not on android. As far as I can tell nothing is returned??!!!!
The code is-
command check_distance_to_school_only
if the environment is "mobile" then
set the defaultFolder to specialFolderPath("external documents")
end if
put URL ("file:saved_currentlocation.txt") into tphone_location
put URL ("file:saved_school_location.txt") into tschool_location
put URL ("file:saved_school_geof_size.txt") into tgeof
put "https://maps.googleapis.com/maps/api/di ... n?origins=" & tphone_location & "&destinations=" & tschool_location & "&mode=walking&key=AIzaSyCF13NFbjMMz7zETlkSoMpuIdVjYr8a9Ew" into tlocation_request
put URL (tlocation_request) into tlocation_response --NOTE just put brackets in to check
put jsontoarray(tlocation_response) into tdistance_Array
put tdistance_Array["rows"]["1"]["elements"]["1"]["distance"]["value"] into tdistance_from_school
put tdistance_from_school into URL ("file:saved_current_distance_from_school.txt")
if tdistance_from_school <= tgeof then
put "in school" into URL ("file:saved_current_location_type.txt")
else
put "out of school" into URL ("file:saved_current_location_type.txt")
end if
end check_distance_to_school_only
Thanks again
Paul