HTTP_POST help
#1

How do you post data with this? And what are the requirements with the URL? Should it be a text file?
There are NO explanations about it on the wiki, hence.

Scenario:
I want to post the name of a player on a uploaded text file. How do I do that?
Reply
#2

i know how u feel ^^ when i tryed to do something with http, i also went to the wiki :P
there's only this: https://sampwiki.blast.hk/wiki/HTTP but that's not enough, cuz there#s so much more u can do with http than just reading from text files.

for example, some months ago when i was playin' around a lil bit with it, i created something like a "log-file"

Код:
new PNx[MAX_PLAYER_NAME];
	new Sx[140];
	new IPx[16];
	new h,minute,sec,day,year,month;
    gettime(h,minute,sec);
	getdate(year,month,day);
	GetPlayerName(playerid,PNx,MAX_PLAYER_NAME);
	GetPlayerIp(playerid,IPx,sizeof(IPx));
	format(Sx,sizeof(Sx),"eastcrips.square7.ch/test.php?filename=testtext.txt&input=[%d.%d.%d|%d:%d:%d]++<Incomming>+Player:%s+|+IP:%s",,day,month,year,h,minute,sec,PNx,IPx);
    HTTP(0, HTTP_POST, Sx, "", "");
it sends a post data to a php file on my ftp.
maybe this helped you somehow
and "+" means " " (space)

btw. u can change the User Agent of ur samp server opening the server file with a hex editor and editing the specific lines :P

if u want, i can also show you the php file (if i still have it ^^)
Reply
#3

Nice, thanks a lot! But how come that allowed to post data, shouldn't it be secure? Or do you need to connect it with FTP of some kind?
Reply
#4

i dont know about that as i didnt went so far with testing...
but you don't need to connect it with ftp, you just need the right URL (to your php file or a text file, when youre just reading)

you can "code" some security if you want
just a example:
PHP код:
<?php
error_reporting
(0);
if(!isset(
$_GET['passCode']))
{
echo 
"Fail!";
exit;
}
else if(
$_GET['passCode'] != "-MY564!!Pass4yyyY'Word-")
{
echo 
"Error 406: NOT Acceptable!";
exit;
}
echo 
"continue the code, password was correct";
?>
here you send the "passCode" you set in your script.
so it's like a password.

or the other way when you've cahnged the User Agent of your server,
just check $_SERVER['HTTP_USER_AGENT']; instead of "passCode"

default User Agent is SAMP 0.3 or so, cant remember
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)