PHP - JSON Object quick snippet to get my rapid chess rating.

Wrote this on my iPad real quick, works. Echos out my current Rapid Chess rating, Chess.com has a read only link and I'm getting the specific data, the JSON gives a whole bunch of other info that can shown however you want and it's dynamic. Just check out the raw JSON from the url in your browser and select your own keys from it aka 'chess_rapid' used in my example. Maybe this helps a newer coder trying to get their own Chess stats. You can make this in an array too if you prefer. Excuse my variable names 😃



$meh = file_get_contents('https://api.chess.com/pub/player/ryan_burleson/stats');
$obj = json_decode($meh);
$poop = $obj->chess_rapid->last->rating;
echo 'Rapid Rank: '.$poop;

// Couple other stats
$tactics = $obj->tactics->highest->rating;
$rapids_record = 'W:'.$obj->chess_rapid->record->win.
' L:'.$obj->chess_rapid->record->loss.
' D:'.$obj->chess_rapid->record->draw;