Steam API - list all games based on TAG - steam-web-api

i've searched over google as well StackOverflow (found only this: Steam API all games)
What I'm trying to achieve is to list all games available in Steam store which will meet following criteria:
- include TAG: TPP
- will be a type: game (not a addon / soundtrack etc.)
How to proceed with that? I have no clue. Searched over github but there are only classes which are suppose to retrive specific user db.
current code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<?php
$url = 'http://api.steampowered.com/ISteamApps/GetAppList/v0002/?key=XXXXXX?tags=1697&os=win&category1=998%2C996&format=json'; // path to your JSON file
$data = file_get_contents($url); // put the contents of the file into a variable
$characters = json_decode($data); // decode the JSON feed
echo $characters[0]->name;
var_dump($data);
var_dump($characters);
?>
<table>
<tbody>
<tr>
<th>Name</th>
</tr>
<?php foreach ($characters as $character) : ?>
<tr>
<td> <?php echo $character->name; ?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>

This API http://api.steampowered.com/ISteamApps/GetAppList/v0002/ does not include steam tags.
You have to check every single app via the app detail call that is mentioned in the answer you linked. In this call you can also sort for app type. You are looking for app type 'game'.
As soon as you have a full database of all apps and their app details you can sort it the way you specified.
To my knowledge there are no other ways than those two calls or getting the tags directly from the steam store page.

Related

How to Load Data From a Json Using Thymeleaf Template

I have a rest api returns a Json value as a Output of the service call.
eg:- https://localhost:8080/getEmployees/loadAll
this returns following json values
eg:-
{
"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]
}
I need to load the following json values to my thymeleaf table.
In normal way returning values in controller using modal in spring can retun values as list like following.
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Employee List</title>
</head>
<body>
<h1>Welcome</h1>
<br>
<h3>Employee List</h3>
<br />
<table border="1">
<tr>
<td>Employee First Name</td>
<td>Employee Last Name</td>
</tr>
<tr th:each="emp : ${empList}">
<td th:text="${emp.firstName}">First Name</td>
<td th:text="${emp.name}">Last Name</td>
</tr>
</table>
</body>
</html>
is there a way to accomplish this using above json using thymeleaf?
You can do something like that using the following structure.
When you call the service
https://localhost:8080/getEmployees/loadAll
you will need to pass the employees data using model.addAttribute.
For instance, let's say you have the following method:
#RequestMapping(value="/getEmployees/loadAll")
String getAllEmployees(Model model) {
model.addAttribute("empList", <your service here that generates the data>);
return "pagenamehere";
}
The above method, will only be executed when you make a call using the following url: https://localhost:8080/getEmployees/loadAll
and it will add your empList data as an attribute. Then, the return string indicates the name of the page that will load. You will need to use your own page with the thymeleaf code.
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Employee List</title>
</head>
<body>
<h1>Welcome</h1>
<br>
<h3>Employee List</h3>
<br />
<table border="1">
<tr>
<td>Employee First Name</td>
<td>Employee Last Name</td>
</tr>
<tr th:each="emp : ${empList}">
<td th:text="${emp.firstName}">First Name</td>
<td th:text="${emp.lastNname}">Last Name</td>
</tr>
</table>
</body>
</html>
Now, thymeleaf will be able to display the given data.
I think that you are a little confused. Thymeleaf templates are compiled on server side generating html code. Then, no thymeleaf code found on client side.
The json data got of the api response is generated on client side.
One way is use javascript to load the api response data into a html table.
Another way can you take is modify the controller that calls to the thymeleaf template to get the JSon value. If you store this response (on an object List named empList on your example) yo can add the object into the Controller response (Model or ModelAndView objects) as a template attribute.

Deleting a record in laravel

I'm new to laravel and I am making a project. and in the project I have a table with records. I also have a delete button in every row of the table. When I click this button I want it to delete the record, however, it is not working. When I click the delete button it sends me to a different page and gives me a 404 error. I really appreciate if someone could help me with my problem.
My view :
<body>
<div class="spelers">
#if (count ($spelers) > 0)
<table id="table" class="table table-hover">
<thead>
<th scope="col">Selectie</th>
<th scope="col"></th>
</thead>
#foreach ($spelers as $speler)
<tr><td><a>{{{ $speler->speler_naam }}}</a></td><td><img src="../../img/edit.png" alt=""></a></td><td><img src="../../img/delete2.png" alt=""></td></tr>
#endforeach
</table>
#else
Er zijn helaas geen clubs beschikbaar
#endif
</div>
</div>
My controller :
public function Destroy($id)
{
SpelerSelectie::where('id', $id)->delete();
return redirect ('/');
}
My routes :
Route::get('/delete/{id}', 'VoetbalController#Destroy');
Since you do delete without a / the link will append the current page you are on. So if you are on /test, then the url will be /test/delete.
To make sure you always end up on the correct url path, you can simply generate the url in the blade file based on the action. It will look like this:
Change
<a href="delete/{{ $speler->id }}">
To
<a href="{{ action('VoetbalController#destroy', $speler->id) }}">
You can now also change the route and the link will still be correctly rendered.
Let me know how that works out.
Named routes allow the convenient generation of URLs or redirects for specific routes.
Route :
Route::get('delete/{id}', 'VoetbalController#destory')->name('voetbal.destroy');
Call :
Delete
change
<a href="delete/{{ $speler->id }}">
To
<a href="/delete/{{ $speler->id }}">
Hope this will help you.
It looks like your url is not being generated properly.
Use this helper method for generation urls.
url()
<a href="{{ url('delete/') . $speler->id }}">

Adding a Logon message to pages

I'm looking to create a log in feature every time users go to various members only pages, which returns them to the original page after logging in. I've seen various answers to this question but none of them seem to include a check feature followed by a return to the original page. At the moment the code I have created doesn't seem to recognize that I have logged in and keeps returning me to the log in form. Any answers will be greatly appreciated. I realize I am using deprecated code but that is the only version my host provider's servers recognize.
Here's the code I am putting at the top of each members page
<?php
session_start();
if($_SESSION['login'] != "yes" )
{
header("Location: main_login.php");
exit();
}
?>
This then opens the main_login.php page
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="password" id="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
On clicking the login button the following code in checklogin.php checks the entries
<?php
$host='.....'; // Host name
$username='.....'; // Mysql username
$password='........'; // Mysql password
$db_name='....'; // Database name
$tbl_name='......'; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start();
$_SESSION['myusername'];
$_SESSION['mypassword'];
header("location:entry_form_european_languages.php");
}
else {
echo "Wrong Username or Password";
}
?>
The last header location refers to the page I would like to return to, which seems to the repeat the process of opening up the login and check in files- as if to indicate that the return page doesn't recognize that the log in was successful.
I would need to add something that was relative to each page, but since I don't know where I am going wrong with the fixed page return, I can't move on to that stage of coding.
I did have an alternative header address which took it to the following page login_success.php which gave the impression that username entries had been accepted, but this doesn't allow me to return to the original page
<?php
session_start();
if(isset($_SESSION[$myusername])){
header("Location:entry_form_european_languages.php");
}
?>
<?php
include '........';//Formatting for the page
?>
<html>
<body>
Login Successful
</body>
</html>
Thanks in advance.
There are a few extra things I needed to add to make the session details work, as follows. This code needs to go ahead of any other code on the page including any html code that relates to character formatting. Although I have coded it out the error reporting line is handy for indicating which line is not being read by the php server, should you have continued problems.
<?php
//error_reporting(E_ALL); ini_set('display_errors', 'On');
session_start();
ob_start();
if(!isset($_SESSION['myusername'])){
header('Location:main_login.php');
}
else if (isset($_SESSION['myusername'])){
}
$myusername=$_SESSION['myusername'];
$Page_Title ='Members Profile';
?>

Adding product description , product image etc in custom Transactional Email for New order

I have created a new custom template using the New order default template in my Magento admin panel.
There are some default variables available to be inserted into the email. But I want to add some other variables like product description into the email template.
In my email after order creation , I want to send description and other details of all products that are present in my cart.
What I have in template is :
<table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<tr>
<td valign="top">
<img src="xyz.jpg"/>
</td>
</tr>
<tr>
<td>
<?php
$order = Mage::getModel('sales/order')->loadByIncrementId("{{var order.increment_id}}");
$items = $order->getAllVisibleItems();
foreach($items as $i):
echo $i->getProductId();
echo $i->getDescription();
echo $i->getDescription();
endforeach;
?>
</td>
</tr>
I want to achieve something like this. Is it possible adding PHP code into the email template and get the variables working. Or I have to define this php code somewhere else? If yes, can you please specify where to make these changes?
Thanks
I dont think u need to load product object in email template it is already loaded if not u can do that but sure u dont need sales order object that sure.
app\design\frontend\default\imsov2\template\email\order\items\order\default.phtml
<?php echo $this->escapeHtml($_item->getDescription()) ?>
and so on...

window.open() not playing well with anchors in Firefox 3

The following javascript, intended to open a new window and jump to a specified anchor, works great in IE. Unfortunately, in Firefox, it opens the window, but it doesn't jump to the anchor.
I've been struggling with this problem for a couple of days now (searches and modifications) to no avail.
If anybody has any insight as to how I can get this to work as intended in both IE and Mozilla browsers, I'd be forever grateful.
Here's the javascript function containing window.open() and the link calling the function containing window.open():
<html>
<head>
<script language=javascript>
function openPopupWindow_Why(sPopupUrl, sPopupLabel)
{
window.open(sPopupUrl, sPopupLabel, 'toolbar=no,resizable=yes,
scrollbars=yes,height=250,width=450', false);
return false;
}
</script>
</head>
<body>
<A onclick="openPopupWindow_Why('MyProfile_WhyAsk.htm#ethnicity', 'Why')"
href="javascript:void(0)" class="WhyAsk">Why do we ask?</a>
</body>
</html>
Here's the HTML anchor on the page that's opened by window.open():
<tr>
<td align="center">
<a name="#ethnicity"> </a>
</td>
</tr>
Try removing the # from the ethnicity anchor name like so:
<tr>
<td align="center">
<a name="ethnicity"> </a>
</td>
</tr>
Works in at least IE, Firefox and Chrome

Resources