steam


json API data with all of its content


I need to show json api data on website. But i am unable to do so am using following script. This just returns data in json format. I want to shownews in proper format along with images.
<?php
$json_url = "http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=570&count=3&maxlength=300&format=json";
$json = file_get_contents($json_url);
$json=str_replace('},
]',"}
]",$json);
$data = json_decode($json, true);
echo "<pre>";
print_r($data);
echo "</pre>";
?>
Based on what you have asked, I hope you will find this helpful:
CSS paste it in between <head><style>here</style></head>
#header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
.news-entry {
color: #606060;
font: 11px/18px Arial,Verdana,sans-serif;
padding: 1px 0;
width: 630px;
}
.news-title {
color: #848484;
font: 10px Arial,Verdana,sans-serif;
width: 630px;
}
.news-title h2 {
border-bottom: 1px dotted #1c4670;
color: #2771a5;
font: 24px/30px "Trebuchet MS",Arial,Verdana,sans-serif;
}
.news-title-info {
height: 22px;
width: 630px;
}
.news-date {
float: left;
line-height: 22px;
padding-left: 18px;
}
.news-author {
float: right !important;
line-height: 22px;
padding-left: 16px;
color:#00C;
}
.featured-news {
float: left;
margin-bottom: 10px;
width: 630px;
}
#footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
Code paste it in between <body>here</body>
<?php
$json_url = "http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=570&count=3&maxlength=300&format=json";
$json = file_get_contents($json_url);
$json = str_replace('},]',"}]",$json);
$data = json_decode($json, true);
$appnews = $data['appnews']['newsitems'];
?>
<div id="header">
<h1>News</h1>
</div>
<div class="featured-news">
<?php
foreach($appnews as $news)
{
?>
<div class="news-entry">
<h2><?php echo $news['title']; ?></h2>
<div class="news-title-info">
<div class="news-date"><?php echo date('l jS \of F Y h:i:s A', $news['date']); ?></div>
<?php
if(!empty($news['author'])){
?>
<div class="news-author">By <?php echo $news['author']; ?></a></div>
<?php
}
?>
</div>
</div>
<div class="news-entry">
<p>
<img width="72" height="90" align="left" alt="Dota 2" src="http://cdn.mos.cms.futurecdn.net/DavzDRpQ36gGQGmiwELPs5-650-80.jpg" style="margin-left: 5px; margin-right: 5px;">
<?php echo $news['contents']; ?>
</p>
<p>
<a class="" target="_blank" href="<?php echo $news['url']; ?>">Read more</a>
</p>
</div>
<?php
}
?>
</div>
<div id="footer">
Some footer here...
</div>
PS: You have to change to path of the image for the image you like as there is no field for news image in the json returned.

Related Links

Node-steam-trade, how to get items names?
Is it possible to create/join a lobby with 4 people, not on friends list, programmatically? [Steam + CSGO]
Steam Web API GetPlayerItems
How to find the path to Steam's sourcemods folder?
Using the SteamWebAPI to send a tradeoffer?
Getting CS:GO player stats
Steam User data
Steam API - Game Controller Support
Steam Web Api: CS:GO Getting Skin name of items
SteamWebAPI IDOTA2Match_570 getScheduledLeagueGames
What identifies a “Dota2” item in Steam?
Steam api get multiplie game achievments&Schema list with 1 call
Steam Achievements API - How to get achievement unlocking date?
Retrieve DotA 2 inventory with ingame order
Steam API ISteamUserStats - How to Get Achievment Image
Steam Web API Getting game list of user with no steam profile

Categories

HOME
json
sed
textwatcher
antivirus
visual-studio-2013
cpu-architecture
phpstorm
checksum
adsense
packer
cakephp-2.9
qt-installer
viber
dlib
equalizer
cratedb
riak
netezza
bootstrap-popover
python-unicode
jogl
device-detection
nmake
hhvm
source-maps
remove-method
samsung-mobile
compare-and-swap
edge-detection
mayavi
positioning
dd-wrt
dhtmlx-scheduler
pari
ipfw
pyscripter
receipt
color-scheme
visualstudio.testtools
polyfills
ssh.net
constants
automator
recycle-bin
nstouchbar
chrome-remote-desktop
slot
pluck
instruction-set
butterknife
uicollectionviewlayout
emgu
gulp-typescript
alter
backstop.js
tomee
icefaces
gameanalytics
metalsmith
ng2-material
gmsmapview
proxygen
void
mysqldumpslow
jericho-html-parser
digits
jai
node-imagemagick
dalekjs
sgml
svcutil.exe
magicalrecord-2.2
sql-server-2012-web
multiple-login
swrl
visual-studio-2003
soa-suite
pep8
graph-coloring
objcmongodb
crocodoc
radchart
tfs-power-tools
scrollto
shim
datacontract
galaxy-tab
zend-form-element
squeel
out-of-browser
getresource
exitstatus
quick-search
microsoft.ink
outlook-form

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App