sending data to php script
How do you send data to a script and get the results?
This is how it was done from a brower from another php script: PHP Code:
|
Re: sending data to php script
Hum, so you want send data from a amxmodx plugin to a php script or send data from a php script to a amxmodx plugin ? who open the connexion ? In fact I think you've no choice because the socket module doesn't allow to listen for tcp connection ( I'm not sure @ 100% ).
edit : I've read your pm too fast ... ... There is to method to send datas to a php script, get and post ... but get is easier :) First we've to know how do a post/get request ... The best way to understand is to analyse a post request. //Open wireshark, which is certainly the best packet sniffer //Open a thread //Write a reply //Record packet & click on reply We get in the first packet PHP Code:
in the second packet PHP Code:
so to do a get request you've just to send: PHP Code:
If you wanna try, just open telnet and do the same thing ... after sending this request, the http server reply on the same connexion. So you can see if your request works with telnet ... The second one with the post ... I'm too lazy :) It's the same thing but datas are after the http header ( here in the second packet ) So, how do to this thing in pawn ... just copy an other code :) Admin mail do the same thing. #include <sockets> new buff[1024] new socket = socket_open( "http://www.amxmodx.org"", 80, SOCKET_TCP, error ); //http uses tcp and the default port is 80 ... formatex( buff, 1023, "get http://forums.alliedmods.net/showthread.php?t=58038^r^n" ); socket_send( socket, buff, 1024); set a task with if (socket_change( socket) socket_recv( socket, buff, 1023) to get the reply... The reply is something like that : PHP Code:
|
Re: sending data to php script
Quote:
|
Re: sending data to php script
|
Re: sending data to php script
I've seen that and still have no idea what to put in socket_send.
Edit: The php script return's a number regarding if the message was sent successfully |
Re: sending data to php script
Lol, I'll sum up my previous post :)
GET request is easier than POST You have to open a TCP connection to the host new socket = socket_open( "http://www.amxmodx.org"", 80, SOCKET_TCP, error ); You have to format a GET request formatex( buff, 1023, "get http://forums.alliedmods.net/showthread.php?t=58038^r^n" ); t is a variable and 58038 the value of t send the request socket_send( socket, buff, 1024); define a task to get the page if (socket_change( socket) //check if there is something waiting in the socket socket_recv( socket, buff, 1023) //put the socket in buff If you wanna try if you php page works, just open telnet, type the request and see the result ... |
Re: sending data to php script
Thanks, I'll see if I can get to work later.
|
Re: sending data to php script
Quote:
to the main php script. How would I send the message using sockets like the code in my first post. This is where I want to send my message and get the result from $result. PHP Code:
|
| All times are GMT -4. The time now is 21:26. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.