HTTP Help - 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 Help (
/showthread.php?tid=577653)
HTTP Help -
DeathKing - 13.06.2015
Код HTML:
PAWN:
new string2[128];
format(string2, sizeof(string2), "?bandate=%d&unbandate=%d&date=%d", BanpInfo[playerid][BDate], BanpInfo[playerid][BUnbanDate], gettime());
HTTP(playerid, HTTP_GET, "localhost/test.php", "", "BanHTTPResponse");
public BanHTTPResponse(index, response_code, data[])
{
new buffer[300];
if(response_code == 200)
{
strmid(buffer, buffer, 200, 400);
format(buffer, sizeof(buffer), "The URL replied: %s", data);
printf("%s", buffer);
}
else
{
format(buffer, sizeof(buffer), "The request failed! The response code was: %d", response_code);
printf("%s", buffer);
}
}
Код HTML:
PHP:
<?php
function ConvertTimeStamp($timestamp)
{
return date('m/d/Y H:i:s', $timestamp);
}
if($_SERVER["REQUEST_METHOD"] == "GET")
{
$x = ConvertTimeStamp($_GET['bandate']);
$y = ConvertTimeStamp($_GET['unbandate']);
$z = ConvertTimeStamp($_GET['date']);
$final = sprintf("%s, %s, %s", $x, $y, $z);
return $final;
}
?>
I would want to know what am i doing wrong on both codes because PHP is sending syntax errors.. but i cant point out where cuz when you open it on a browser.. its giving no errors
Re: HTTP Help -
BroZeus - 13.06.2015
Thats because you are not giving the $_GET parameters in the url specified in the PAWN script, you are formatting those parameters in
string2 but you are not sending them via HTTP...
So correct code would be :
Код:
PAWN:
new string2[128];
//format with localhost/test.php
format(string2, sizeof(string2), "localhost/test.php?bandate=%d&unbandate=%d&date=%d", BanpInfo[playerid][BDate], BanpInfo[playerid][BUnbanDate], gettime());
HTTP(playerid, HTTP_GET, string2, "", "BanHTTPResponse");//use string2 here
And why are you using PHP script for this if this can be done via PAWN..
here is what you need to do it in PAWN
https://sampforum.blast.hk/showthread.php?tid=347605
I think so that using PHP method is slower than PAWN method.