I'm really new to this sort of stuff; my background is in C# mainly. Could anyone point me in the right direction?

I need to set a script to automatically parse some JSON into an SQL database whenever the data has been updated on the server.

I look at this file first which returns the file location for the data and the last modified time stamp: http://us.battle.net/api/wow/auction/data/medivh.

I've spent the last hour googling, but I can't find an adequate answer. To summarise, the script needs to run every 15 minutes or so, check if the timestamp changed and if so, and pull the new data and enter it into an SQL database.

Do I need to use PHP to parse and insert the JSON data into the database? If so, how do I manage to run the PHP code every x minutes?

  • 3
    If nothing else, please be mindful of SQL injection attacks.
    – Jim G.
    Commented Dec 23, 2011 at 2:17
  • Thank you, just read up on it: en.wikipedia.org/wiki/SQL_injection
    – ChrisO
    Commented Dec 23, 2011 at 2:22
  • 1
    What part are you having trouble with, parsing the JSON, putting data into a database, or both? Commented Dec 23, 2011 at 2:49
  • Hi Mike, it would be more of a general direction of what I need to investigate at the moment so I'm struggling with both the parsing and inserting to the database. Sorry for the generalised question, some more specific questions at this stage would be: Should I use php for both the parsing and putting it into the database? How do I automatically fire that every x minutes?
    – ChrisO
    Commented Dec 23, 2011 at 3:04
  • 3
    Why don't you write a C# console program that runs as a scheduled task? Use the WebRequest class.
    – Jim G.
    Commented Dec 23, 2011 at 3:46

1 Answer 1


Parsing JSON: Assuming that you are on 5.2.x or above, you can use json_decode to parse the json data.

As for executing the script every x minutes, read up on cron jobs.

Edit: Answer is based on the assumption that you are on Linux and want to do this in PHP.

  • Thanks for your answer. This was exactly the route I ended up going after doing some reading up. It is working a treat at the moment :)
    – ChrisO
    Commented Dec 31, 2011 at 3:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.