dtp19819 2011-10-04 12:33
浏览 326
已采纳

将Steam API信息提取到页面

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!

  • 写回答

1条回答 默认 最新

  • dpg76975 2011-10-04 12:50
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害