I'm looking at having some weather and ocean conditions on my site, updating regularly from the local weather site. Can anyone give me some sort of idea how to do this? The sort of data I'm talkin about is this http://www.weathermap.co.nz/boating/kaikoura-peninsula
You can use the RSS feed. http://www.weathermap.co.nz/feed/boating/kaikoura-peninsula Then use PHP simplexml_load_string and cURL to suck in the data, format it, and display it on your page. http://php.net/manual/en/function.simplexml-load-string.php http://ditio.net/2008/06/19/using-php-curl-to-read-rss-feed-xml/ Or use a third party RSS parser to display it.
Thanks for that, I am a big NOOB and only have basic to intermediate HTML skills so will have a good read over this. Thanks!
Here's something to get your started. Save it as whatever.php, then put it on your website. (You'll need CURL and PHP5) <?php function My_simplexml_load_file($URL) { $ch = curl_init($URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $xml = simplexml_load_string(curl_exec($ch)); curl_close($ch); return $xml; } ?> <?php $url='http://www.weathermap.co.nz/feed/boating/kaikoura-peninsula'; $xml = My_simplexml_load_file($url); if ($xml!=''){ foreach ($xml->channel->item as $item){ $description = $item->description; echo $description; } } ?> PHP: Keep in mind that there's a certain etiquette to pinching peoples feeds. It's probably a good idea to either ask first, or at least give the source a good back link.
You're a Legend. I've got the data on there, now I just need to fiddle around with the format of it somehow. I will also double check with this site that it is okay to do this and give them backlinks - I don't see it as a big problem as I've seen other sites using the data and referencing them as the owners. I'm always learning from this site thanks to people like you.
You won't be able to get it to display the same as the website - at least not without a lot of stuffing around with PHP.
Simple, use their API's http://www.programmableweb.com/api/weather-underground http://weather.weatherbug.com/desktop-weather/api.html http://www.weather.com/services/xmloap.html http://www.weather.gov/xml/ A few of the favorites...
Thanks, But I need reliable New Zealand Weather resources and Marine Weather too, not sure if these sites quite cover that?
I emailed that site, they had no problem with me posting their feeds on my site. He also said Whats the difference between RSS posts and APIs?