2014-09-15 2 views
1

Google 타임 존 API에 연결하고 오프셋이 있는지 여부를 파생시킬 json 메시지를 반환하는 다음 코드가 있습니다.Google 시간대 API : 요청 루프

질문 : 여기에 루프를 사용하고 그것을 반복 일에 대한 올바른 메시지를 반환하고 다음 반복이

가 { "ERRORMESSAGE"는 말한다 : ". 제공되는 API 키가 잘못" "상태": "REQUEST_DENIED"} "여기

내 코드입니다. 내가 샘플 날짜를 사용

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 + "&timestamp=" +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  

내 목표는이 모든 일이 사람들에게 3 일 통지 실행하는 것입니다 나아가 라. 귀하의 의견을 감사하십시오. API 키를 사용하여 무료 계정으로 사용해 볼 수 있습니다.

감사

답변

2

문제가 있습니다 : 첫 번째 실행 후 변수 strArtifactoryUrl를 재설정하지 않으며, 쓸모없는 URL을 렌더링, 모든 실행에 다른 위치에 다른 타임 스탬프를 추가 그에.

strBaseUrl이라는 또 다른 변수를 정의하고 위치를 추가하는 행에서 변수 strArtifactoryUrl을 형성하십시오.

strBaseUrl = "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 = strBaseUrl + "location=" +StrLeft(CStr(lv),"~") 

     REM UTC timestamp 
     Set usD = New NotesDateTime("12/01/2014 00:00:00") 
     Call usD.Adjustday(3)  
     strArtifactoryUrl = strArtifactoryUrl + "&timestamp=" + _ 
      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 
+0

가 동의 :

는 결과 코드가 될 것입니다. 그 어리석은 실수를 놓쳤다. 그것을 지적 주셔서 감사합니다. – Kalyan