/**
  * Fetches the games this user owns
  *
  * @see getGames()
  * @throws SteamCondenserException if an error occurs while parsing the
  *         data
  */
 private function fetchGames()
 {
     $gamesData = $this->getData($this->getBaseUrl() . '/games?xml=1');
     $this->games = array();
     $this->playtimes = array();
     foreach ($gamesData->games->game as $gameData) {
         $appId = (int) $gameData->appID;
         $game = SteamGame::create($appId, $gameData);
         $this->games[$appId] = $game;
         $recent = (double) $gameData->hoursLast2Weeks;
         $total = (double) str_replace(',', '', $gameData->hoursOnRecord);
         $playtimes = array((int) ($recent * 60), (int) ($total * 60));
         $this->playtimes[$appId] = $playtimes;
     }
 }
Example #2
0
function checkversion()
{
    $settings = getsettings();
    if ($settings['usegrowl']['config'] == 'yes') {
        require_once 'lib/growl/class.growl.php';
        $growlip = $settings['growlip']['config'];
        $growlpass = $settings['growlpass']['config'];
    }
    if ($settings['usetwitter']['config'] == 'yes') {
        require_once 'lib/twitter/twitter.php';
        $consumerkey = $settings['consumerkey']['config'];
        $consumersecret = $settings['consumersecret']['config'];
        $OAuthToken = $settings['OAuthToken']['config'];
        $OAuthTokenSecret = $settings['OAuthTokenSecret']['config'];
        $twitter = new Twitter("{$consumerkey}", "{$consumersecret}");
        $twitter->setOAuthToken("{$OAuthToken}");
        $twitter->setOAuthTokenSecret("{$OAuthTokenSecret}");
    }
    if ($settings['useboxcar']['config'] == 'yes') {
        require_once 'lib/boxcar/boxcar_api.php';
        $boxemail = $settings['boxemail']['config'];
    }
    $gametypes = gametypes();
    foreach (array_keys($gametypes) as $game) {
        $version = $gametypes[$game][version];
        if (!$version) {
            $version = "1.0";
        }
        $longname = $gametypes[$game][longname];
        $expired = $gametypes[$game][expired];
        $appid = $gametypes[$game][appid];
        $shortname = $gametypes[$game][shortname];
        print "{$game} for {$version}\n";
        // simple feedback part if needed
        try {
            $game = SteamGame::checkUpToDate($appid, $version);
        } catch (Exception $e) {
            echo "Seems {$appid} with version {$version} doesn't like to be probed\n";
            echo "Setting gametype as 'up to date' , dont want to start stuff without proper knowledge\n";
            echo "Seems like this is the error {$e}\n";
            $game = "1";
        }
        if ($expired != "yes") {
            if ($game != "1") {
                mysql_query_trace("UPDATE games SET expired='yes' WHERE shortname = '{$shortname}'");
                if ($settings['useemail']['config'] == 'yes') {
                    $subject = "A update for {$longname} seems to be out, go check out the buzz...";
                    $newstuff = getupdates($appid, 'last');
                    $message = "A update for {$longname} seems to be out, go check out the buzz...\n" . $newstuff;
                    $smtpmails = $settings['emailalert']['config'];
                    $allmails = explode(",", $smtpmails);
                    foreach ($allmails as $sendto) {
                        mail($sendto, $subject, $message, null);
                    }
                }
                if ($settings['usegrowl']['config'] == 'yes') {
                    $growl = new Growl();
                    //$growl->setAddress($growlip, $growlpass);
                    $connection = array('address' => '$growlip', 'password' => '$growlpass');
                    $growl->notify($connection, "{$type}", "UPDATE: {$shortname}", "A update for {$longname} seems to be out, go check out the buzz...");
                }
                if ($settings['usetwitter']['config'] == 'yes') {
                    try {
                        $twitter->statusesUpdate("A update for {$longname} seems to be out, go check out the buzz...");
                    } catch (Exception $e) {
                        echo "{$e} went wrong";
                    }
                }
                if ($settings['useboxcar']['config'] == 'yes') {
                    include "config.php";
                    $b = new boxcar_api($boxcarapi, $boxcarsec);
                    $emails = explode(",", $boxemail);
                    foreach ($emails as $boxalert) {
                        try {
                            $b->notify($boxalert, 'UPDATE', 'A update for ' . $longname . ' seems to be out, go check out the buzz...');
                        } catch (Exception $e) {
                            echo 'something went wrong with boxcar';
                        }
                    }
                }
            }
        }
    }
}
Example #3
0
<html>
<body>

<?php 
require_once "steam/SteamUser.php";
require_once "steam/SteamGame.php";
?>

<h1>Steam API Test </h1>

<?php 
//Handler for building this API from Terminal CLI:
if (substr(php_sapi_name(), 0, 3) == "cli") {
    $userID = $argv[1];
} else {
    $userID = $_GET["id"];
}
// Pull it from the apache / CGI / whatever
//Call the SteamUser constructor with either the 17-digit Steam Community ID
//or their custom URL (i.e. robinwalker)
//$user = new SteamUser($userID);
$game = new SteamGame(440);
//New SteamGame with TF2's AppID set.
$news = $game->getNewsItems();
print_r($news);
?>


</body>
</html>
 /**
  * Returns the base Steam Community URL for the stats contained in this
  * object
  *
  * @return string The base URL used for queries on these stats
  */
 public function getBaseUrl()
 {
     return self::_getBaseUrl($this->user->getId(), $this->game->getId());
 }