Posting to a PHP script
Does anyone know if it is possible to POST to a PHP script via SM?
If so, what would be the best way of going about it? |
Re: Posting to a PHP script
If there is no direct method implemented, you could use an intermediary page.
You load the page which will then post to the actual php page you need. |
Re: Posting to a PHP script
What I'm looking to do is give people the ability to send data to a global database, but I'd like to have some control on what comes back.
So rather than give people mySQL details, where they could insert anything they wanted, I would build a PHP API that people can send data to, like a mySQL query. This is where I am a bit stuck, as I'm not sure how I would POST the data from SM. |
Re: Posting to a PHP script
GET can be done via Causing a Hidden MOTD window to open a url (invisible). However your limited to 255 characters.
But that wont' work for POST. Your going to have to use Sockets You can use my Plugin as a guideline https://forums.alliedmods.net/showthread.php?t=117577 |
Re: Posting to a PHP script
Is there any chance you could dumb it down a bit so its a tad easier to understand?
This would be my first time I've used sockets and I'm not 100% sure where I would start. |
Re: Posting to a PHP script
Code:
#include <sourcemod> Sockets 3.0.0 Alpha base64.inc I use base64 to easily encode the data which can the easily decoded by PHP I stripped out everything bare minimum that is needed. In this case you would simply call Command_PostExample to execute the connection. And you can setup your PHP script to save some data to a file to see what all happens and what not. |
Re: Posting to a PHP script
Genius! I've managed to get a reply from my PHP script and PHP picks up the variables I'm sending.
Only problem I'm having now is on the Receive I get back a lot of junk such as the headers. I also get a 'c' before my value and a '0' after the value. Is there a way to just get back just the page data? (http://zmstat.co.uk/capture.php is what I'm testing with) Also, thanks for your awesome post :) |
Re: Posting to a PHP script
I haven't tried the receive myself but here is a decent looking post
http://forums.alliedmods.net/showpos...&postcount=274 |
Re: Posting to a PHP script
Well, I've already managed to print the data, It's just that the response data includes all of the headers too.
Anyone know if I can get rid of those? |
Re: Posting to a PHP script
as far as i remember the header ends with \n\n
|
All times are GMT -4. The time now is 14:03. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.