By specifying the Steam URL, the name of the game can be read out of the Steam page.
Submitting without an invalid Steam URL would not be possible.
You would save some work and misspelled titles would be impossible.
It would be a safety and automation measure.
I have a small prototype.
Here is a video as I imagined:
https://youtu.be/suJxIGM07kU
(It is in double speed because typing is not very exciting to watch. )
Of course this is implementation work again.
I'm just writing down my ideas. That's what this chapter is for.
Replace the game name field with a Steam URL field
- PieMonster
- SGC Admin
- Posts: 810
- Joined: Tue Dec 29, 2009 9:52 pm
- Location: Panorama City, CA
- Contact:
Re: Replace the game name field with a Steam URL field
@domidodo,
talked to my web guy about this and it seems the way we're doing it now works best. Thanks.
talked to my web guy about this and it seems the way we're doing it now works best. Thanks.
FREE disc and case art for STEAM games: http://www.steamgamecovers.com/
Re: Replace the game name field with a Steam URL field
That could be interesting for the web guy .
It's a small PHP class for easy use of the Steam API.
If he wants to automate a few things, this class will do some work for him. I wrote it. So I give you the rights to use them
Below are application examples.
And a small picture of what the code looks like when it runs:
It's a small PHP class for easy use of the Steam API.
If he wants to automate a few things, this class will do some work for him. I wrote it. So I give you the rights to use them
Below are application examples.
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>Steam Feeder</title>
<meta charset="utf-8">
<!-- __________________________________________ PHP library ________________________________________-->
<?php
class SteamFeeder {
public static function getObjectCategoryFromUrl($url)
{
$startIndex = strpos($url, '.com/agecheck/');
if($startIndex !== false)
{
$url = substr($url, $startIndex+14);
}
else
{
$startIndex = strpos($url, '.com/');
if($startIndex !== false)
{
$url = substr($url, $startIndex+5);
}
else
{
return null;
}
}
$endIndex = strpos($url, '/');
if($endIndex !== false)
{
$url = substr($url, 0, $endIndex);
}
return $url;
}
public static function getObjectIdFromUrl($url)
{
$category = SteamFeeder::getObjectCategoryFromUrl($url);
$startIndex = strpos($url, '/'.$category.'/');
if($startIndex !== false)
{
$url = substr($url, $startIndex+2+strlen($category));
$endIndex = strpos($url, '/');
if($endIndex !== false)
{
$url = substr($url, 0, $endIndex);
}
return $url;
}
return null;
}
public static function getApiUrlFromUrl($url)
{
return SteamFeeder::getApiUrl(SteamFeeder::getObjectCategoryFromUrl($url), SteamFeeder::getObjectIdFromUrl($url));
}
public static function getApiUrl($category, $id)
{
$apiUrl = null;
switch($category)
{
case "app":
$apiUrl = "http://store.steampowered.com/api/appdetails?appids=";
break;
case "sub":
$apiUrl = "http://store.steampowered.com/api/packagedetails?packageids=";
break;
case "bundle":
break;
}
if($apiUrl == null)
{
return null;
}
return $apiUrl . $id;
}
public static function getObjectDataFromUrl($url)
{
return SteamFeeder::getObjectData(SteamFeeder::getObjectCategoryFromUrl($url), SteamFeeder::getObjectIdFromUrl($url));
}
public static function getObjectData($category, $id)
{
if($category == null || $id == null)
{
return null;
}
$apiUrl = SteamFeeder::getApiUrl($category, $id);
if($apiUrl == null)
{
return null;
}
try{
$json = file_get_contents($apiUrl);
$obj = json_decode($json);
$obj = $obj->{$id};
if($obj->success)
{
return $obj->data;
}
}catch (Exception $e) {
//echo $e->getMessage();
}
return null;
}
public static function getOptimizedUrlFromUrl($url)
{
return SteamFeeder::getSteamUrl(SteamFeeder::getObjectCategoryFromUrl($url), SteamFeeder::getObjectIdFromUrl($url));
}
public static function getSteamUrl($category, $id)
{
return "https://store.steampowered.com/".$category."/".$id."/";
}
}
?>
</head>
<body>
<!-- __________________________________________ Test ________________________________________-->
<form action="" method="get">
Steam URL: <input type="text" name= "url">
<input type="submit" value="Get Data">
</form>
<br/><hr><br/>
<?php
if(isset($_GET["url"]) && $_GET["url"] != "")
{
$url = $_GET["url"];
echo "<fieldset><legend>The input from the user</legend>";
echo "<b>Input:</b> " . $url . "<br/>";
echo "</fieldset>";
echo "<br/>";
echo "<fieldset><legend>These are all functions that do not need the Steam API</legend>";
echo "<b>Url:</b> " . SteamFeeder::getOptimizedUrlFromUrl($url) . "<br/>";
echo "<b>Category:</b> " . SteamFeeder::getObjectCategoryFromUrl($url) . "<br/>";
echo "<b>Id:</b> " . SteamFeeder::getObjectIdFromUrl($url) . "<br/>";
echo "<b>API:</b> " . SteamFeeder::getApiUrlFromUrl($url) . "<br/>";
echo "</fieldset>";
echo "<br/>";
echo "<fieldset><legend>Here are some data that the API returns</legend>";
$data = SteamFeeder::getObjectDataFromUrl($url);
if($data != null)
{
echo "<b>Name:</b> " . $data->name . "<br/>";
echo "<b>Required age:</b> " . $data->required_age . "<br/>";
if($data->is_free)
{
echo "<b>Price:</b> It is free<br/>";
}
else
{
// Price will return without comma. Must also be inserted manually here
$price = $data->price_overview->initial;
$price1 = substr($price, 0, strlen($price)-2);
$price2 = substr($price, strlen($price)-2);
$price = $price1 . "." . $price2;
echo "<b>Price:</b> " . $price . " " . $data->price_overview->currency . "<br/>";
}
echo "<b>Website:</b> " . $data->website . "<br/>";
}
else
{
echo "Object not found";
}
echo "</fieldset>";
}
?>
</body>
</html>
- PieMonster
- SGC Admin
- Posts: 810
- Joined: Tue Dec 29, 2009 9:52 pm
- Location: Panorama City, CA
- Contact:
Re: Replace the game name field with a Steam URL field
From my web guy:
"For the replacing game name field thing, it's much more convenient for people to enter a game name (and even be able to select from the list that shows up) than to look up the Steam URL and copy and paste that. It also allows us to change the name if needed, like take out "the" and make modifications. A game name is added only once if it doesn't already exist in the database. And we want to approve covers for new games anyway, so automating the adding of new games isn't really needed. There are also some games (adult only) we don't want to support, so doing it this way allows us to filter it."
"For the replacing game name field thing, it's much more convenient for people to enter a game name (and even be able to select from the list that shows up) than to look up the Steam URL and copy and paste that. It also allows us to change the name if needed, like take out "the" and make modifications. A game name is added only once if it doesn't already exist in the database. And we want to approve covers for new games anyway, so automating the adding of new games isn't really needed. There are also some games (adult only) we don't want to support, so doing it this way allows us to filter it."
FREE disc and case art for STEAM games: http://www.steamgamecovers.com/