【问题标题】:vbs to get data from api callvbs 从 api 调用中获取数据
【发布时间】:2009-08-17 03:41:26
【问题描述】:

这是检索返回的 api 调用数据的问题。我发现 Request.Form("param2") 不起作用。

例如:在 Windows 服务器中运行的 .vbs 脚本中,我对外部脚本进行 api 调用。然后api脚本返回一个字符串数据。

例如:param1=baby;param2=banana;param3=haha

我发现在.vbs里面,如果我使用request.form、request.getparam等,都不起作用。

vbs 只能得到一个字符串?如果是这样,我必须手动将字符串拆分为数组,然后通过引用数组索引来读取它。

有人知道什么简单的方法吗?

【问题讨论】:

    标签: vbscript return


    【解决方案1】:

    如果您可以从外部脚本中以您提到的格式获取字符串,则应该可以将其拆分两次。第一个拆分将是键/值对,然后下一个拆分将是键,然后是值。

    我没有对此进行测试,但以下应该是一个好的开始。

    ' 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"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-13
      • 2022-08-05
      相关资源
      最近更新 更多