2009-08-17 37 views
0

這是關於檢索返回的api調用數據的問題。我發現Request.Form(「param2」)不起作用。例如:在Windows服務器中運行的.vbs腳本中,我執行一個API調用外部腳本。然後,api腳本返回一個字符串數據。vbs從api調用獲取數據

例如:參數1 =嬰兒;參數2 =香蕉;參數3 =哈哈

我發現裏面的.vbs,如果我使用的Request.Form,request.getparam等,都不能正常工作。

vbs只能得到一個字符串?如果像那樣,那麼我必須手動將字符串拆分爲arrray,然後通過引用數組索引來讀取它。

任何人都知道任何簡單的方法?

回答

0

如果您可以按照您提到的格式從外部腳本中獲取字符串,則應該可以將其拆分兩次。第一個分割將是鍵/值對,然後下一個分割將是鍵,然後是值。

我還沒有測試過這個,但以下應該是一個好的開始。

' here we get the string from the external script 
' the expected results will be in the form: param1=value1;param2=value2;etc. 
str = Call ExternalScriptFunction 

Dim Params 
Dim KeyValue 

Params = Strip(ExternalScriptFunction, ";", -1) 

' Params should now contain an array of key-value pairs, such that: 
' Params(0) = "param1=value1" 
' Params(1) = "param2=value2" 
' etc. 

KeyValue = Split(Params(0), "=", -1) 

' KeyValue should now contain an array of the key and value for the 1st element, so: 
' KeyValue(0) = "param1" 
' KeyValue(1) = "value1"