Photo by Pixabay on Pexels.com
steamのAPIを使用して積みゲーを調べてみました.積みゲー有り
この投稿は1年以上前に公開されました。 現在の情報とは異なる可能性がありますので、ご了承ください。
おはようございます.xAIの申請に通らなかったので来月のQiitaの投稿を何にしようかなと考えてた所、ふと積みゲーのことが頭に浮かんできたので、Steam APIとかあるのかなと調べてみました.そしたらAPIが在ったのでさっそく作ってみました.
ソースコードはgithubにもあげているので試してみてください.こちらのソースコードをコピペするよりお手軽ですよ.
https://github.com/taoka3/steam/tree/main
<?php
require 'config.php';
class steam
{
public $result;
public function getOwnedGames($urls = 'http://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?')
{
$params = http_build_query([
'key'=>APIKEY,
'steamid'=>STEAMID,
'include_appinfo'=>1,
'include_played_free_games'=>0,
//'appids_filter'=>''
]);
$this->result = file_get_contents($urls.$params,true);
return $this;
}
public function viewOwnedGames()
{
$data = json_decode($this->result);
foreach($data->response->games as $val){
$tumiGames = (int)$val->playtime_forever === 0?' [積みゲー]':'';
printf('ゲーム名:%s プレイ時間:%02d時%02d分%s<br>',$val->name,(int)($val->playtime_forever / 60),(int)($val->playtime_forever % 60),$tumiGames);
}
return $this;
}
}
(new steam)->getOwnedGames()->viewOwnedGames();
因みに実行結果は下記になります.

明日へ続く.