Raised This Month: $305 Target: $400
 76%   Almost there!

Help with Steam API returning json


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 12-05-2016 , 08:17   Help with Steam API returning json
Reply With Quote #1

Hello, it's been a while. I have a project at university where i am trying to retrieve game price with steam api in a json return. Thing it, i get this error:

XMLHttpRequest cannot load https://store.steampowered.com/api/a...price_overview. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'mywebsite.com' is therefore not allowed access.


and the code is something like this.

PHP Code:
var SteamStoreURL "https://store.steampowered.com/api/appdetails/?appids=" GameID "&cc=gb&filters=price_overview";


$.
getJSON(SteamStoreURL, function(data)
{
    var 
URLString JSON.parse(data);

    
console.log(URLString);
}); 
I really cannot get it to work. I am not a super web developer or something like that, but any help would be appreciated. I just want to retrieve the game current price using json javascript.
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 12-05-2016 , 12:34   Re: Help with Steam API returning json
Reply With Quote #2

I would suggest ask on stack overflow.
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective
addons_zz is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-05-2016 , 13:54   Re: Help with Steam API returning json
Reply With Quote #3

It happens because of the Same-origin policy. There may be ways to avoid it (search, I'm not sure), but if you are not only creating the page but also have a server, download the page on the server and serve it to your JavaScript through an API.
klippy is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-05-2016 , 15:11   Re: Help with Steam API returning json
Reply With Quote #4

There are quite a few pre-existing proxies out there for bypassing same-origin requirements if you don't want to host your own - obviously best not to rely on one for anything critical though.
__________________
asherkin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:33.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode