Save data to file per one hour.

  • 1
  • Question
  • Updated 6 years ago
How to integrated data from my location and save txt file per hour to the file. PHP
show data on www it's plus for me ??
please some sugestion, or examples.
Photo of szarywilk81

szarywilk81

  • 3 Posts
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
It's not clear to understand what you need to obtain.

Have you issues in finding coordinates for a location point?
Have you troubles reading the designated WU API URL in PHP?
You need a script to be executed every hour? If using linux, there's crontab for that.
Does the PHP example at http://www.wunderground.com/weather/a... work (as in "I am able to read some example data") for your project?

Remind that programming and system issues can be not related to the wunderground API ecosystem.
Photo of szarywilk81

szarywilk81

  • 3 Posts
  • 0 Reply Likes
afelicioni thx for Your reply.
What i need to do?

I need to use api for display whether on my webside. php mybe the best.
I could run script from cron.
I have key:) my location it's IMALOPOL8

second problem:
Need this data from api save to the file. example (txt) or built array in php with result.
then from php need to get data about raining and problably rainning.

OK ?
Photo of szarywilk81

szarywilk81

  • 3 Posts
  • 0 Reply Likes
{'location'}->{'city'};
$temp_f = $parsed_json->{'current_observation'}->{'temp_f'};
echo "Current temperature in ${location} is: ${temp_f}\n";
?>

what i need to write to location ? city ?here ??
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Mumble, let me get one step at time

Your reference URL is something like the following:http://api.wunderground.com/api/YOUR_KEY_HERE/conditions/q/pws:IMALOPOL8.json
In the above, first replace YOUR_KEY_HERE with your Weather Underground API key you subscribed.
Replace conditions when you need to get more data than the current. for example, different forecast features area available, see the documentation area for the best choice that can fit your needs.
Replace json with xml when you need to work with xml.

if you're able to write some code like in the example, and your host configured PHP to fetch remote URLs, you can display datas on your website.

After that, if you can get the remote data, you can save what you want in files. I advice to query google for a tutorial about your favourite language; for example "save files in php", since here would be a discussion outside the weather API usage topic.

I think the last post can be solved if you are able to discover your perfect URL, you just pasted a piece of example that simply writes to output some variables, so it's better for you to call the http://api.wund.... URL in your browser and study the HTML source to spot the point of the wanted data.