Sending Data to a PHP Script

Discussion in 'Plugin Development' started by Waizujin, Feb 29, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Waizujin

    Greetings everyone. Since I have been unable to find a java developer to help me with my project, I am going to have to learn how to do this myself.

    What I want to do is collect server data, such as number of online players, user logins and logouts, etc and store it in a text or json file. Then when the plugin receives a request from my PHP script, it will forward the text or json file data to my PHP script, then delete the data in those files on the Java side and start anew.

    Writing to a file shouldn't be hard, I can do that. It's the sending the file contents to the PHP script to parse and insert into a database is the issue. I do not know how to send data from Java to PHP.

    If I use sockets (I assume the only way to do this efficiently) how do I send the data on the Java end. I can do the PHP, just need to know the java stuff.
     
  2. Offline

    AdvsNoob

    Why not send from Java to a database (Mysql) then have the PHP script read it that way? That's what I would do. No need to create and delete random files over and over again, you can just update the database
     
  3. Offline

    flatd

    Why not just use GET in php so your just adding stuff to the end of a link to collect data and you can send it by using a link by using stringbuilder.
     
  4. Offline

    masteroftime

  5. Offline

    flatd

    POST is not really I good choice because you need to enter stuff into text boxes and all not by links so GET is best.
     
  6. Offline

    Abrupt

    you can send POST data without actually needing input forms...
     
  7. Offline

    flatd

    Yes but GET is easier to start with when your just learning.
     
  8. Offline

    kevhog

    I recommend listening with a socket, it's easy and you can use input/output streams to directly send your info without JSON files or a MySQL DB or any other random bull.

    I was going to post some of my code here, but there's way too much for what you're doing and I'm not spending the effort to cut out parts. Check out MineQuery's source code, it does exactly what you're trying to do.
    https://github.com/vexsoftware/minequery/tree/master/java/net/minestatus/minequery
     
  9. Offline

    kumpelblase2

    If I may raise my voice. If you take a look at the resource section, the are two libraries for sockets.
    TCP Sockets Library and Transmit. Sure you can use something else, but if you don't want to work on that as much you can use those. Choose what you like best.
     
Thread Status:
Not open for further replies.

Share This Page