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

Class: Services_Weather_Weatherdotcom

Source Location: /Services_Weather-1.4.7/Weather/Weatherdotcom.php

Class Overview

Services_Weather_Common
   |
   --Services_Weather_Weatherdotcom

This class acts as an interface to the xml service of weather.com. It searches for given locations and retrieves current weather data as well as forecast for up to 5 days.


Author(s):

Version:

  • Release: 1.4.7

Copyright:

  • 2005-2011 Alexander Wirtz

Methods


Inherited Variables

Inherited Methods

Class: Services_Weather_Common

Services_Weather_Common::calculateDewPoint()
Calculate dewpoint from temperature and humidity This is only an approximation, there is no exact formula, this one here is called Magnus-Formula
Services_Weather_Common::calculateHumidity()
Calculate humidity from temperature and dewpoint This is only an approximation, there is no exact formula, this one here is called Magnus-Formula
Services_Weather_Common::calculateMoonPhase()
Calculates the moon age and phase
Services_Weather_Common::calculateSunRiseSet()
Calculates sunrise and sunset for a location
Services_Weather_Common::calculateWindChill()
Calculate windchill from temperature and windspeed (enhanced formula)
Services_Weather_Common::convertDistance()
Convert distance between km, ft and sm
Services_Weather_Common::convertPressure()
Convert pressure between in, hpa, mb, mm and atm
Services_Weather_Common::convertSpeed()
Convert speed between mph, kmh, kt, mps, fps and bft
Services_Weather_Common::convertTemperature()
Convert temperature between f and c
Services_Weather_Common::getUnitsFormat()
Returns the selected units format
Services_Weather_Common::getWeatherIcon()
Gets a number corresponding to a weather icon.
Services_Weather_Common::polar2cartesian()
Convert polar coordinates to cartesian coordinates
Services_Weather_Common::setCache()
Enables caching the data, usage strongly recommended
Services_Weather_Common::setDateTimeFormat()
Changes the representation of time and dates (see http://www.php.net/date)
Services_Weather_Common::setHttpOption()
Sets an option for usage in HTTP_Request objects
Services_Weather_Common::setHttpProxy()
Sets the proxy for HTTP requests
Services_Weather_Common::setHttpTimeout()
Sets the timeout in seconds for HTTP requests
Services_Weather_Common::setUnitsFormat()
Changes the representation of the units (standard/metric)

Class Details

[line 84]
This class acts as an interface to the xml service of weather.com. It searches for given locations and retrieves current weather data as well as forecast for up to 5 days.

For using the weather.com xml-service please visit http://www.weather.com/services/xmloap.html and follow the link to sign up, it's free! You will receive an email where to download the SDK with the needed images and guidelines how to publish live data from weather.com. Unfortunately the guidelines are a bit harsh, that's why there's no actual data-representation in this class, just the raw data. Also weather.com demands active caching, so I'd strongly recommend enabling the caching implemented in this class. It obeys to the times as written down in the guidelines.

For working examples, please take a look at docs/Services_Weather/examples/weather.com-basic.php docs/Services_Weather/examples/weather.com-extensive.php



[ Top ]


Method Detail

enablePreFetch   [line 230]

void enablePreFetch( bool $preFetch)

Enables pre-fetching of data in one single request
  • Access: public

Parameters:

bool   $preFetch     

[ Top ]

getForecast   [line 620]

PEAR_Error|array getForecast( [string $id = ""], [int $days = 5], [string $unitsFormat = ""])

Get the forecast for the next days
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $id     
int   $days     Values between 1 and 5
string   $unitsFormat     

[ Top ]

getLinks   [line 441]

PEAR_Error|array getLinks( [string $id = ""])

Returns the data for the promotional links belonging to the ID
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $id     

[ Top ]

getLocation   [line 489]

PEAR_Error|array getLocation( [string $id = ""])

Returns the data for the location belonging to the ID
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $id     

[ Top ]

getWeather   [line 537]

PEAR_Error|array getWeather( [string $id = ""], [string $unitsFormat = ""])

Returns the weather-data for the supplied location
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $id     
string   $unitsFormat     

[ Top ]

searchLocation   [line 365]

PEAR_Error|array|string searchLocation( string $location, [bool $useFirst = false])

Searches IDs for given location, returns array of possible locations or single ID
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION
  • Throws: PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA
  • Access: public

Parameters:

string   $location     
bool   $useFirst     If set, first ID of result-array is returned

[ Top ]

searchLocationByCountry   [line 426]

bool searchLocationByCountry( [string $country = ""])

Returns only false, as weather.com offers no country listing via its XML services
  • Deprecated:
  • Access: public

Parameters:

string   $country     

[ Top ]

setAccountData   [line 212]

void setAccountData( string $partnerID, string $licenseKey)

Sets the neccessary account-information for weather.com, you'll receive them after registering for the XML-stream
  • Access: public

Parameters:

string   $partnerID     
string   $licenseKey     

[ Top ]


Documentation generated on Mon, 22 Oct 2012 13:30:20 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.