Stefan recently added support for making cURL requests through a GScript wrapper. This allows you to make both POST and GET requests serverside, without requiring Stefan to enable TSocket on your server (as was previously required for making POST requests).
This class is meant both to help document cURL and to be used to simplify repeated requests. It allows you to use a single function to POST or GET data.
To use the class, all you need to do is join it and call the appropriate function.
Example (GET):
PHP Code:
temp.ip = this.get("http://automation.whatismyip.com/n09230945.asp");
echo("server IP: " @ temp.ip);
I don't see any request to use cURL over requestURL for GET requests, except that cURL is possibly more reliable.
Example (POST):
PHP Code:
// paste to pastebin.graalcenter.org
temp.data = {
{"text", "This paste was submitted by *an npcserver*."},
{"syntax", "Markdown"}
};
temp.pasteURL = this.post("http://pastebin.graalcenter.org/paste.php", temp.data);
echo("paste URL: " @ temp.pasteURL);
The data array you pass is made into a query string which is then submitted as POST data. Note that you
can send binary data (e.g. a PNG) without base64encoding it. Keys and values are both escaped, so you can use any characters in them you want.
func_http class:
http://pastebin.graalcenter.org/read.php?id=02042935537