HappySV Posted February 14, 2016 Share Posted February 14, 2016 (edited) Hello, at the exit Multiplayer and with the help of an admin we have devised an API to display the status of the servers from my site.Today that has changed site I decided to recreate the page but I have a problem.I actually managed to get the "index.php and TruckMPApi.php" file but it still does not work as you can see this address.http://status.cobra-gaming.eu/I suspect that something is missing for reading server information but I do not know where to look.I attached to this post a link to the files winrar "index and TruckMPApi"cordiallySorry for my English but I'm French and google translation is not too developed. Edited February 14, 2016 by FirestarteR93 Removed the link to the archive due to security reasons Link to comment Share on other sites More sharing options...
0 CJMAXiK Posted February 14, 2016 Share Posted February 14, 2016 (edited) You don't need to use TruckMPApi, coz' it is excessive for your situation. Try this (just an example): <?php $servers = json_decode(@file_get_contents("http://api.ets2mp.com/servers/"), true); var_export($servers["response"]);?> `true` in the first line says, that you want to use $servers as array, not as object. If you don't know, khow to use arrays, taking a look at this help: http://php.net/manual/en/language.types.array.php So, you can use this array smth like that (as an example, of course): foreach ($servers["response"] as $key => $server) { echo '<p>'.$server["name"].' - '.$server["players"].'/'.$server["maxplayers"].'</p>';} Edited February 14, 2016 by CJMAXiK 2 Link to comment Share on other sites More sharing options...
0 Mari' Posted February 14, 2016 Share Posted February 14, 2016 I do not recommend sharing the code of your page... 1 Link to comment Share on other sites More sharing options...
0 HappySV Posted February 14, 2016 Author Share Posted February 14, 2016 Thank you for your help, it will advance much, but I know how just selected some server including those of europecordially ps: Sorry to have to share my source code. instantly I have not thought of. Link to comment Share on other sites More sharing options...
0 CJMAXiK Posted February 14, 2016 Share Posted February 14, 2016 ^ You need to learn some PHP basics. Link to comment Share on other sites More sharing options...
0 Web Developer _J-M Posted February 15, 2016 Web Developer Share Posted February 15, 2016 Also the way you're doing it will cause you to get ban from the API. Because each time someone visit your page. It will send a request to the API and if there's too many request to the API for unknown reason, it will cause your IP to be banned. Also WebSocket is way too overkill to do it. You can do it easily with 10 lines of code~ Link to comment Share on other sites More sharing options...
0 HappySV Posted February 15, 2016 Author Share Posted February 15, 2016 So I prefer abandoned, I will not be banned from servers ETS2 why ...Too bad I could try ..And the WebSocket, I'm really new at this matter that's why I'm asking for help ..Anyway thank you for helping me in my first approach.Cordially. Link to comment Share on other sites More sharing options...
0 Web Developer _J-M Posted February 15, 2016 Web Developer Share Posted February 15, 2016 Just load the API every min. Insert it into database and get the data from the Database. So make 2 different script. It should be pretty easy. 1 Link to comment Share on other sites More sharing options...
0 Philip1212 Posted March 1, 2016 Share Posted March 1, 2016 Topic inactive. closed & moved. Link to comment Share on other sites More sharing options...
Question
HappySV
Hello, at the exit Multiplayer and with the help of an admin we have devised an API to display the status of the servers from my site.
Edited by FirestarteR93Today that has changed site I decided to recreate the page but I have a problem.
I actually managed to get the "index.php and TruckMPApi.php" file but it still does not work as you can see this address.
http://status.cobra-gaming.eu/
I suspect that something is missing for reading server information but I do not know where to look.
I attached to this post a link to the files winrar "index and TruckMPApi"
cordially
Sorry for my English but I'm French and google translation is not too developed.
Removed the link to the archive due to security reasons
Link to comment
Share on other sites
8 answers to this question
Recommended Posts