26.09.2013, 15:52
I have this function (basically straight from the sa-mp wiki) and a php page. When I send the HTTP request the website is supposed to respond but I always get status code 1. Help?
On filterscript init I send the request (url point to my PHP script):
MyHttpResponse:
(This always prints ""The request failed! The response code was: 1, Data was (nothing)")
if you surf to the PHP script with those parameters (click here) you can see it should be responding with "The server responded with the result: 100,95,0.5,6.54" but it doesn't.
PHP script:
On filterscript init I send the request (url point to my PHP script):
pawn Код:
HTTP(0, HTTP_GET, "http://www.sandec.net/dev/scontrol/server/scontrol.php", "health=100&armour=95&velocity=0.5&speed=6.54", "MyHttpResponse");
pawn Код:
forward MyHttpResponse(index, response_code, data[]);
public MyHttpResponse(index, response_code, data[])
{
new buffer[ 128 ];
if(response_code == 200) //Did the request succeed?
{
format(buffer, sizeof(buffer), "The URL replied: %s", data);
}
else
{
format(buffer, sizeof(buffer), "The request failed! The response code was: %d, Data was %s", response_code, data);
}
printf(buffer);
}
if you surf to the PHP script with those parameters (click here) you can see it should be responding with "The server responded with the result: 100,95,0.5,6.54" but it doesn't.
PHP script:
PHP код:
<?php
$result = implode(',', $_GET);
echo 'The server responded with the result: ' . $result . PHP_EOL;
?>