Hi,
I am trying to send some xml from spiderbasic to a purebasic cgi and after processing the xml pass back some different xml.
Does anyone have an example of how to this can be done or point me in the right direction please?
Posting and Receiving XML
Re: Posting and Receiving XML
SpiderBasic:
PureBasic (myTestCgi.exe):
Greetings ... Peter
Code: Select all
EnableExplicit
Procedure myCallback(Success, Result$, UserData)
Debug "Success: " + Str(Success)
Debug "Result$: " + Result$
Debug "UserData: " + Str(UserData)
EndProcedure
HTTPRequest(#PB_HTTP_Post, "http://localhost/cgi-bin/myTestCgi.exe", "<hello />", @myCallback(), 42)
Code: Select all
EnableExplicit
If Not InitCGI()
End
EndIf
Define XML.s = "<nodata />"
Define BufferSize = ReadCGI()
If BufferSize
If CGIBuffer()
XML = PeekS(CGIBuffer(), BufferSize, #PB_Ascii)
EndIf
EndIf
If ParseXML(0, XML) And XMLStatus(0) = #PB_XML_Success
SetXMLNodeText(MainXMLNode(0), "from cgi")
XML = ComposeXML(0, #PB_XML_NoDeclaration)
EndIf
WriteCGIHeader("Access-Control-Allow-Origin", "*") ; to avoid cross-call-errors (replace / remove the asterisk if possible)
WriteCGIHeader(#PB_CGI_HeaderContentType, "text/html", #PB_CGI_LastHeader)
WriteCGIString(XML)
Re: Posting and Receiving XML
Thanks Peter.
What is the last argument 42 for on the httprequest?
What is the last argument 42 for on the httprequest?
Regards
Andy
Andy
Re: Posting and Receiving XML
https://en.wikipedia.org/wiki/Phrases_f ... g_.2842.29 
BTW, nice example Peter, straight to the point.

BTW, nice example Peter, straight to the point.