libcurl POST new question
BlitzMax Forums/Brucey's Modules/libcurl POST new question
| ||
Hi Brucey! I have a newb question...Im trying to get data from a post Local curl:TCurlEasy = TCurlEasy.Create() Local data:String = "service=1" curl.setOptString(CURLOPT_POSTFIELDS, data) curl.setOptString(CURLOPT_URL, "http://localhost/validator.php") curl.perform() ' post away! but the data goes directly to console. I havenīt found a way to retrieve that data myself... how can i do it? Thanks! |
| ||
You can get the response with curl.ToString() or you can let curl write it to a stream by calling curl.setWriteStream() |
| ||
Hi Htbaa, I tried using the curl.toString() method but i get nothing. As for the curl.SetWriteStream() i did this:Local curl:TCurlEasy = TCurlEasy.Create() Local data:String = "service=1" curl.setOptString(CURLOPT_POSTFIELDS, data) curl.setOptString(CURLOPT_URL, "http://localhost/validator.php") Local bk:TBank = CreateBank(5) Local bs:TBankStream = CreateBankStream(bk) curl.setWriteStream(bs) curl.perform() ' post away! Print "StreamSize:" + StreamSize(bs) SeekStream(bs, 0) Repeat Print "data:" + ReadByte(bs) Until bs.Eof() And it worked :) thanks a lot man |
| ||
For curl.ToString() to work you need to activate it by calling curl.setWriteString(). You could also use my rest.mod to do this by the way. |
| ||
It worked too! Thanks a lot... i'll give it a try to your module too, thanks! |