Created
January 23, 2025 18:01
-
-
Save jaoltr/0a05d3ae4cc31caad0302210d6906f57 to your computer and use it in GitHub Desktop.
Zoho Flow Deluge Custom Function To Fix Address Via Google Maps API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string address_fix_google_maps(string customer_address) | |
{ | |
// Define your API key and the base URL for Google Maps Places API | |
apiKey = "Your_Google_API_Key"; | |
baseUrl = "https://places.googleapis.com/v1/places:searchText"; | |
fields = "places.formattedAddress"; | |
hdrs = Map(); | |
hdrs.put("Content-Type","application/json"); | |
hdrs.put("X-Goog-Api-Key",apiKey); | |
hdrs.put("X-Goog-FieldMask",fields); | |
params = Map(); | |
params.put("textQuery",customer_address); | |
response = invokeurl | |
[ | |
url :baseUrl | |
type :POST | |
parameters:params.tostring() | |
headers:hdrs | |
detailed:true | |
content-type:"application/json" | |
]; | |
info response; | |
if(response.getJSON("responseCode") = 200) | |
{ | |
return response.getJSON("responseText").getJSON("places").getJSON("formattedAddress"); | |
} | |
else | |
{ | |
return "NOTFOUND " + customer_address; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment