Services_Weather
[ class tree: Services_Weather ] [ index: Services_Weather ] [ all elements ]

Source for file globalweather-basic.php

Documentation is available at globalweather-basic.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at                              |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Alexander Wirtz <alex@pc4p.net>                             |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: globalweather-basic.php,v 1.4 2004/05/07 14:41:36 eru Exp $
  20.  
  21. require_once "Services/Weather.php";
  22.  
  23. // Object initialization - error checking is important, because of
  24. // handling exceptions such as missing PEAR modules or not being online
  25. $globalweather &Services_Weather::service("GlobalWeather"array("debug" => 2));
  26. if (Services_Weather::isError($globalweather)) {
  27.     die("Error: ".$globalweather->getMessage()."\n");
  28. }
  29.  
  30. /* Erase comments to enable caching
  31. $status = $globalweather->setCache("file", array("cache_dir" => "/tmp/cache/"));
  32. if (Services_Weather::isError($status)) {
  33.     echo "Error: ".$status->getMessage()."\n";
  34. }
  35. */
  36.  
  37. $globalweather->setUnitsFormat("metric");
  38. $globalweather->setDateTimeFormat("d.m.Y""H:i");
  39.  
  40. // First get code for location
  41. $search $globalweather->searchLocation("Koeln / Bonn");
  42. if (Services_Weather::isError($search)) {
  43.     die("Error: ".$search->getMessage()."\n");
  44. }
  45.  
  46. // Now iterate through available functions for retrieving data
  47. foreach (array("getLocation""getWeather""getForecast"as $function{
  48.     $data $globalweather->$function($search);
  49.     if (Services_Weather::isError($data)) {
  50.         echo "Error: ".$data->getMessage()."\n";
  51.         continue;
  52.     }
  53.  
  54.     var_dump($data);
  55. }
  56. ?>

Documentation generated on Mon, 11 Mar 2019 14:17:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.