【问题标题】:Steam Api Json to PHPSteam Api Json 转 PHP
【发布时间】:2014-07-24 04:28:23
【问题描述】:

抱歉我的英语不好。

我想将 steamapi (json) 转换为 php 变量。我该怎么做?

我正在使用此代码:

$api = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=5E78FFBEBC11204E33F589AA5E027F82&steamids=76561197960435530"; $json = file_get_contents($api); $decoded = json_decode($json); print_r($decoded->{'response'}->{'players'}->{'steamid'});

我要显示 Steamid。

【问题讨论】:

    标签: php json api steam


    【解决方案1】:

    json_decode 不行吗?这应该可以让您在 $decoded 中有 json。如果你想要 steamid,你必须这样做:

    $obj->{'steamid'};
    

    希望对你有帮助。

    【讨论】:

      【解决方案2】:

      试试这个

      print_r($decoded->response->players[0]->steamid);
      

      players 是一个数组,所以你必须取它的第一个元素。

      【讨论】:

      • 工作正常,谢谢! :D 解决了
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-20
      • 2016-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      相关资源
      最近更新 更多