views:

88

answers:

1

Hi there,

Here's an issue on retrieving returned api call data. I found that Request.Form("param2") not working.

Eg: inside .vbs script that run in a windows server, I do an api call to external script. Then the api script return a string data.

Eg: param1=baby;param2=banana;param3=haha

I found that inside .vbs, if I use request.form, request.getparam etc, all not working.

vbs only can get a string? If like that then I have to manually split the string into arrray, then read it by referring to array index.

Anyone know any easy way?

A: 

If you can get the string from the external script in the format you mentioned, you should be able to split it twice. The first split would be the key/value pairs, then the next split would be the key, then the value.

I have not tested this, but the following should be a good start.

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