Get Steam API Information on Page

I found a great Valve API for APIs, and now I'm wondering how I can put specific information one at a time. Example: $steam['response']['players']['personastate'] . This should not be this decision. I just typed something :)

The request will look like this:

 { "response": { "players": [ { "steamid": "{hidden}", "communityvisibilitystate": 3, "profilestate": 1, "personaname": "nhagyavi", "lastlogoff": 1317692549, "commentpermission": 1, "profileurl": "http:\/\/steamcommunity.com\/id\/nhagyavi\/", "avatar": "http:\/\/media.steampowered.com\/steamcommunity\/public\/images\/avatars\/c2\/c25479aeea82f85eb1134bfcc8e064dcef1d361f.jpg", "avatarmedium": "http:\/\/media.steampowered.com\/steamcommunity\/public\/images\/avatars\/c2\/c25479aeea82f85eb1134bfcc8e064dcef1d361f_medium.jpg", "avatarfull": "http:\/\/media.steampowered.com\/steamcommunity\/public\/images\/avatars\/c2\/c25479aeea82f85eb1134bfcc8e064dcef1d361f_full.jpg", "personastate": 1, "realname": "Erik Edgren", "primaryclanid": "103582791429525632", "timecreated": 1106321372, "gameserverip": "217.163.23.35:7777", "gameextrainfo": "Red Orchestra 2: Heroes of Stalingrad", "gameid": "35450", "gameserversteamid": "90083758048089092", "loccountrycode": "SE", "locstatecode": "{hidden}", "loccityid": {hidden} } ] } } 

How to fix it? Thanks in advance!

+4
source share
1 answer

Looks like JSON. You need json.decode

 $json_object= file_get_contents("http://api.steampowered.com/"); $json_decoded = json_decode($json_object); //var_dump($json_decoded); echo $json_decoded->response->players[0]->lastlogoff; 

Outputs

 1317711877 
+2
source

All Articles