Fetch Steam API information to page
I have found a great Steam API from Valve them self and I wonder now how I can put the specific information one by one. Example: $steam['response']['players']['personastate']
. It doesn't need to be that solution. I just typed something :)
The request will be like this one below:
{
"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 do I fix this? Thanks in advance!
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
精彩评论