2009-08-17 95 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"