BeryJu BeryJu - 5 months ago 22
PHP Question

Steam WebAPI: Get the price of an app

Is there a possibility to get the Price of a Game from Steam over the WebAPI? I am using PHP.

Answer

You can check the GetSupportedAPIList (available here) and see that there doesn't seem to be a way to get the Price of an app.

Edit Here's the code to do what you're asking for in your comment:

The sample code is a bit bigger because I had to set the encoding for the Euro sign to display properly, but you should be able to extract what you need from it:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body>
<?php

$string = "Other Data in the document<div class=\"game_purchase_price price\" itemprop=\"price\">49,99€</div>Some More Data!";
$regex = "/\<div class\=\"game_purchase_price price\" itemprop\=\"price\"\>(.*?)\<\/div\>/";
preg_match_all($regex, $string, $matches);

for($i = 0; $i < count($matches[1]); $i++)
{
    $match = $matches[1][$i];
    echo $match;
}

?>
    </body>
</html>

I added "garbage" in the string, so you could see that the expression would be able to extract the price even if a bigger document contained the div.

Comments