DubStepMad Posted January 14, 2018 Share Posted January 14, 2018 (edited) Hello, I am trying to retrieve members MP names from a database and display that. Here is the current php code being used: <?php $sqlget = 'SELECT * FROM players'; $sqldata = mysqli_query($dbcon, $sqlget); while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)){ $json = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXXXXXXXXXXXXAABB80E2C4C45E1779B&steamids='.$row['playerid'].''); $parsed = json_decode($json); foreach($parsed->response->players as $player){ } $online = $player->personastate; if ($online == '1'){ $bcolor = '4px solid #6eea15'; } else{ $bcolor = ''; } $json = file_get_contents('https://api.truckersmp.com/v2/player/'.$row['playerid'].''); $data = json_decode($json); $mpname = $data->name; echo'<li id="fleet" >'; echo "<center><img style='height:auto; width:auto; border:$bcolor;' class='img-circle' src='" . $player->avatarfull . "'></center>"; echo '<center><p style="margin-top: 65%;">'. $player->personaname . '<p></center>'; echo '<center><p style="margin-top: 65%;">'. $mpname . '<p></center>'; echo'</li>'; } ?> The error I am currently getting is that the $mpname doesn't contain the correct data needed. (I am new to using all APIs and still learning). Thank you in advance. Edited January 14, 2018 by [TSRVTC] DubStepMad removed api key for steam Into Code Link to comment Share on other sites More sharing options...
WooQash Posted January 14, 2018 Share Posted January 14, 2018 Try: $mpname = $data->response->name; Thanks for SteamAPI Key Link to comment Share on other sites More sharing options...
DubStepMad Posted January 14, 2018 Author Share Posted January 14, 2018 Just now, WooQash said: Try: $mpname = $data->response->name; Thanks for SteamAPI Key Will try and yeah changing that now XD forgot I left that. Into Code Link to comment Share on other sites More sharing options...
DubStepMad Posted January 14, 2018 Author Share Posted January 14, 2018 Works, Thank you! Into Code Link to comment Share on other sites More sharing options...
WooQash Posted January 14, 2018 Share Posted January 14, 2018 Such a private council. Don't abuse the TruckersMP API. Developers don't like heavy traffic on their servers. I know something about this Link to comment Share on other sites More sharing options...
DubStepMad Posted January 14, 2018 Author Share Posted January 14, 2018 1 minute ago, WooQash said: Such a private council. Don't abuse the TruckersMP API. Developers don't like heavy traffic on their servers. I know something about this Okay, how can I avoid this? Into Code Link to comment Share on other sites More sharing options...
WooQash Posted January 14, 2018 Share Posted January 14, 2018 Not calling the API several hundred or tens of times per hour. Earlier I had a simple game map based on the ETS2Map API and TruckersMP API, which within a one minute refreshed several times for several dozen people (about 200-300 queries per minute in total). Access was blocked and the developers were angry at me. Link to comment Share on other sites More sharing options...
DevOps Kat_pw Posted January 14, 2018 DevOps Share Posted January 14, 2018 7 hours ago, WooQash said: Not calling the API several hundred or tens of times per hour. Earlier I had a simple game map based on the ETS2Map API and TruckersMP API, which within a one minute refreshed several times for several dozen people (about 200-300 queries per minute in total). Access was blocked and the developers were angry at me. There are better ways of doing things rather than doing 3 req/sec 24/7 against our services. When you hit the api harder than our game servers, yeah, we're gonna notice. It's the internet, play fair. Learn to cache your queries and realize we're not on the same scale as your service probably is. Sure, maybe it's not a lot of load if one person does it, but we don't have just one person queuing and abusing us. Traffic Cameras : twitch.tv/kat_pw | Ets2Map : ets2map.comKat_pw Status:[CCTV #1] Status:[CCTV #2] Status:[CCTV #3] Status: Link to comment Share on other sites More sharing options...
DevOps Kat_pw Posted January 14, 2018 DevOps Share Posted January 14, 2018 Again, we're fine with you using our api(s). Just take into consideration it's a shared service with other users. Don't abuse it. When working on a feature, think to yourself, "does this data really change all that much? Maybe I should cache it locally for a week instead of spawning a request every-time I need it." We're not out to get you.. Traffic Cameras : twitch.tv/kat_pw | Ets2Map : ets2map.comKat_pw Status:[CCTV #1] Status:[CCTV #2] Status:[CCTV #3] Status: Link to comment Share on other sites More sharing options...
DubStepMad Posted January 14, 2018 Author Share Posted January 14, 2018 8 minutes ago, Kat_pw said: Again, we're fine with you using our api(s). Just take into consideration it's a shared service with other users. Don't abuse it. When working on a feature, think to yourself, "does this data really change all that much? Maybe I should cache it locally for a week instead of spawning a request every-time I need it." We're not out to get you.. Thank you and yeah I will read up on caching. Into Code Link to comment Share on other sites More sharing options...
DevOps Kat_pw Posted January 14, 2018 DevOps Share Posted January 14, 2018 4 minutes ago, [TSRVTC] DubStepMad said: Thank you and yeah I will read up on caching. Redis is <3 Traffic Cameras : twitch.tv/kat_pw | Ets2Map : ets2map.comKat_pw Status:[CCTV #1] Status:[CCTV #2] Status:[CCTV #3] Status: Link to comment Share on other sites More sharing options...
Recommended Posts