I have the following code that connects to google timezone api and returns a json message from which i would derive if there is an offset or not.
Question: I am using a for loop here and it returns correct message for the iteration 1 and for the next iteration it says
{ "errorMessage" : "The provided API key is invalid.", "status" : "REQUEST_DENIED" }"
Here is my code:
strArtifactoryUrl = "https://maps.googleapis.com/maps/api/timezone/json?"
apiKey = "AIzaSyCoJ1l1MkioDqYQNIDn7WsZjKv_inwktYM"
LatLongStr = "40.7142700,-74.0059700~United States###51.5085300,-0.1257400~United Kingdom"
Set session = New NotesSession
latVar = Split(LatLongStr,"###")
ForAll lv In latVar
If CStr(lv) <> "" Then
REM location based on latitude and longitude
strArtifactoryUrl = strArtifactoryUrl + "location=" +StrLeft(CStr(lv),"~")
REM UTC timestamp
Set usD = New NotesDateTime("12/01/2014 00:00:00")
Call usD.Adjustday(3)
strArtifactoryUrl = strArtifactoryUrl + "×tamp=" +CStr(getTimeStamp(usD.Lslocaltime)) &"&key=" & apiKey
c = StrRight(CStr(lv),"~")
Set httpObject = CreateObject("Msxml2.XMLHTTP")
Call httpObject.open("GET", strArtifactoryUrl, False)
Call httpObject.Send()
Print httpObject.responseText
End If
End forall
Function getTimeStamp(dt As Variant) As Long
Dim dtEpoch As New NotesDateTime("1/1/1970 00:00:00")
Dim dtTemp As New NotesDateTime(Now)
dtTemp.LSLocalTime = dt
getTimeStamp = dtTemp.TimeDifference(dtEpoch)
End Function
I used a sample date. My aim is to run this every day notify people 3 days in advance. Appreciate your inputs. You can use the API key to try at your as it a free account.
Thanks