events[0][ev]:event1
events[0][ts]:1374269099
events[0][pos]:0
events[1][ev]:event2
events[1][ts]:1374269100
events[1][pos]:0
events[2][ev]:event3
events[2][ts]:1374269100
events[2][pos]:0
foreach($_POST['events'] as $event){
echo $event . ' ';
}
postString = ""
ander =""
pos% = 0
for each event in events
eventString = "events["+AnyToString(pos%)+"][ev]="+AnyToString(event["ev"])
eventString = eventString+"&events["+AnyToString(pos%)+"][ts]="+AnyToString(event["ts"])
eventString = eventString+"&events["+AnyToString(pos%)+"][pos]="+AnyToString(event["pos"])
postString = postString + ander + eventString
ander = "&"
pos% = pos% + 1
end for
xfer.PostFromString(postString)
'******************************************************
'HELPERS
'******************************************************
'******************************************************
'itostr
'
'Convert int to string. This is necessary because
'the builtin Stri(x) prepends whitespace
'******************************************************
Function itostr(i As Integer) As String
str = Stri(i)
return strTrim(str)
End Function
'******************************************************
'Trim a string
'******************************************************
Function strTrim(str As String) As String
st=CreateObject("roString")
st.SetString(str)
return st.Trim()
End Function
'try to convert an object to a string. return invalid if can't
'******************************************************
Function AnyToString(any As Dynamic) As dynamic
if any = invalid return "invalid"
if isstr(any) return strTrim(any)
if isint(any) return itostr(any)
if isbool(any)
if any = true return "true"
return "false"
endif
if isfloat(any) return Str(any)
if type(any) = "roTimespan" return itostr(any.TotalMilliseconds()) + "ms"
return invalid
End Function
"TheEndless" wrote:
You have to serialize the data somehow, either to the querystring or to the post body (url encoded name/value pairs, json, or xml). How would you submit the data via a website or another app? The same would be true in BrightScript.