| Blockland Forums > Modification Help |
| How to get torque to connect to a url (GET requests) |
| (1/2) > >> |
| Ipquarx:
Like lets say I wanted to connect to somewebsite.com/stuff.php?user=asdf&pass=1234, How do I do that? |
| Brian Smithers:
--- Quote from: Ipquarx on January 22, 2012, 12:25:03 PM ---Like lets say I wanted to connect to somewebsite.com/stuff.php?user=asdf&pass=1234, How do I do that? --- End quote --- BlockOS does this, check it out. |
| Ipquarx:
I actually did check BlockOS, but when i tryed to use HTTPObject.get(host:port, url), it just gave the 2 familiar rtb onconnect and disconnect error lines instead of echoing any lines. |
| Greek2me:
This will download a file. --- Code: ---$server = "greekmods.webs.com"; $port = 80; $dir = "/mods/Gamemode_Slayer/Updater/changeLog_Latest.txt"; new TCPObject(tcp); function tcp::onConnected(%this) { %this.send("GET" SPC $dir SPC "HTTP/1.0\nHost:" SPC $server @ "\n\n"); } function tcp::onLine(%this,%line) { warn("LINE:" SPC %line); //ONLY NEEDED IF SAVING THE FILE if(strPos(%line,"Content-Length:") >= 0) %this.length = getWord(%line,1); //ONLY NEEDED IF SAVING THE FILE if(%line $= "") %this.setBinarySize(%this.length); } //ONLY NEEDED IF SAVING THE FILE function tcp::onBinChunk(%this,%chunk) { if(%chunk < %this.length) return; %path = "config/server/TCP example.txt"; %this.saveBufferToFile(%path); %this.disconnect(); } tcp.connect($server @ ":" @ $port); --- End code --- That is set to download a file from my website. Simply change $server and $dir (and pick less generic names for everything). |
| Ipquarx:
Will try that. |
| Navigation |
| Message Index |
| Next page |