Created
April 26, 2016 13:56
-
-
Save Chronial/a8b2ec3546a0efeb4bf3bc1f875bf8ae to your computer and use it in GitHub Desktop.
Steam API Wrapper for DSCM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ids = explode(',', $_GET['ids']); | |
$ids = array_filter($ids, 'is_numeric'); | |
$data = ask_api($ids); | |
foreach ($data as $k => $v){ | |
echo $k . ',' . ($v ? "True" : "False") . "\n"; | |
} | |
function ask_api($ids){ | |
// game_id of Dark Souls | |
$ds_id = 211420; | |
$url_base = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXXXXXXXXXXXXXXXXXXXXXXX&steamids="; | |
$url = $url_base . implode(',', $ids); | |
$response = file_get_contents($url); | |
$data = json_decode($response, true); | |
$out = array(); | |
foreach ($data['response']['players'] as $player){ | |
$is_online = ($player['gameid'] == $ds_id); | |
$out[$player['steamid']] = $is_online; | |
} | |
return $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment