[HTTP] Why is my HTTP/PHP script not working? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HTTP] Why is my HTTP/PHP script not working? (
/showthread.php?tid=466201)
[HTTP] Why is my HTTP/PHP script not working? -
Sinner - 26.09.2013
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):
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");
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);
}
(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:
PHP код:
<?php
$result = implode(',', $_GET);
echo 'The server responded with the result: ' . $result . PHP_EOL;
?>
Re: [HTTP] Why is my HTTP/PHP script not working? -
Misiur - 26.09.2013
https://sampwiki.blast.hk/wiki/HTTP
Quote:
The URL you want to request. (Without 'http://')
|
Cheers
Re: [HTTP] Why is my HTTP/PHP script not working? -
Sinner - 26.09.2013
Quote:
Originally Posted by Misiur
|
Thanks, that worked! I am now receiving a HTTP_ERROR_MALFORMED_RESPONSE error though. Any idea what the server should be responding?