[HTTP] Why is my HTTP/PHP script not working?
#1

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;
?>
Reply
#2

https://sampwiki.blast.hk/wiki/HTTP

Quote:

The URL you want to request. (Without 'http://')

Cheers
Reply
#3

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)