Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
3  
If nothing else, please be mindful of SQL injection attacks. –  Jim G. Dec 23 '11 at 2:17
    
Thank you, just read up on it: en.wikipedia.org/wiki/SQL_injection –  ChrisO Dec 23 '11 at 2:22
1  
What part are you having trouble with, parsing the JSON, putting data into a database, or both? –  Mike O'Connor Dec 23 '11 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 Dec 23 '11 at 3:04
2  
Why don't you write a C# console program that runs as a scheduled task? Use the WebRequest class. –  Jim G. Dec 23 '11 at 3:46

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
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 Dec 31 '11 at 3:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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