2012-01-17 73 views
1

我想用從經典ASP的Pingdom的REST API,但下面的代碼: -Pingdom的REST API從傳統的ASP

' setup the URL 
baseUrl = "https://api.pingdom.com/api/2.0/checks" 

' setup the request and authorization 
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP") 
http.open "GET", baseUrl, False 
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 
http.setRequestHeader "userpwd", "aaaaaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbb" 
http.setRequestHeader "App-Key", "ccccccccccccccccccccccccccccccc" 

' send the HTTP data 
http.send 

給我的錯誤: -

{"error":{"statuscode":401,"statusdesc":"Unauthorized","errormessage":"User credentials missing"}} 

所以我身份驗證沒有被正確傳遞,看起來它不應該在requestheader中傳遞,但我不知道應該如何完成。

感謝

感謝亞歷克斯K.和他人的利益,正確的語法是: -

' setup the URL 
baseUrl = "https://api.pingdom.com/api/2.0/checks" 

Response.Write fullUrl 
' setup the request and authorization 
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP") 
http.open "GET", baseUrl, False, "emailaddress", "password" 
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 
http.setRequestHeader "App-Key", "keykeykeykeykeykeykeykeykeykey" 

' send the HTTP data 
http.send 

:-)

回答