http_proxy(STRING* proxy,var port)
Sets a http proxy server for the connection to the internet. If no proxy is used, this function needs not to be called.
http_sendpost(STRING* url, STRING* data)
Sends http data with the "post" methode to a web server and returns a httpID. With this httpID the transfer can be controlled with functions like http_status.
If no data has to be sent, NULL can be passed for the data string. After the post is finished, the httpID has to be freed with http_free.
http_status(var httpid)
Returns information about a http post:
2 connection problem
1 data was received
0 waiting for data from the server
-1 invalid httpid
http_result(var httpid, STRING* result)
Stores the received data of a http post in the result string and returns the length of the received data.
http_free(var httpid)
Frees the httpID of a http post and stops the transfer. Must be called after each http post.
Parameters:
proxy - proxy server (example: "proxy-host.com"), STRING* or char*.
port - port of the proxy servers (example: 8080).
url - url of the web server (example: "http://www.testserver.com/svlist.php"), STRING* or char*
data - string containing the data to be sent (example: "svname=gameserver&players=16&pw=yes"), STRING*, char*, or NULL.
result - STRING* to receive the result data of the http post oeration.
httpid - httpID of the post, returned by http_post().
Remarks:
- Up to 5 http posts can be run at the same time.
- All STRING* arguments can also be char* with at least 3 characters (except for http_result).
- All functions return -1 if an error occured and 1 if everything went ok (except if something else is mentioned in the function description).
- The plugin acknet.dll must be loaded and the file acknet.h must be included for using the ftp functions.
Version:
P
LC
Example:
#include <acknex.h>
#include <default.c>
#include <acknet.h>
STRING* ip_str = " ";
// start the script "ip.php" on a remote server, and return the caller's IP address
function main()
{
var id = http_sendpost("http://coniserver.net/scratch/ip.php","");
while (!http_status(id))
wait(1);//wait for the server to reply
if (http_status(id) == 1) { //transfer successful?
http_result(id,ip_str); //get the replied IP
printf(_chr(ip_str));
} else
error("Error during transfer!");
http_free(id); //always cleanup the httpid!
sys_exit(NULL);
}
ip.php:
<?php
echo "Your IP address: " . $_SERVER['REMOTE_ADDR'];
?>
See also:
ftp functions
► latest
version online