Skip to content

Instantly share code, notes, and snippets.

@Chronial
Created April 26, 2016 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chronial/a8b2ec3546a0efeb4bf3bc1f875bf8ae to your computer and use it in GitHub Desktop.
Save Chronial/a8b2ec3546a0efeb4bf3bc1f875bf8ae to your computer and use it in GitHub Desktop.
Steam API Wrapper for DSCM
<?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