共用方式為


Extending the Weather Bar in Outlook

Learn how to plug in a third-party weather web service for the Weather Bar in Outlook 2013, to provide weather conditions data for a user-chosen location.

Weather Bar overview

The Weather Bar in Outlook displays weather conditions and forecast for a geographic location. A user can choose one or multiple locations, and conveniently see weather data in the Weather Bar in the calendar module. Figure 1 shows the Weather Bar displaying a three-day forecast for New York, NY.

圖 1: Outlook 中的天氣列

Weather Bar showing forecast for New York.

Settings for the Weather Bar are saved with the user's profile. Depending on the type of Outlook account, the settings may roam with the user on all computers that the user logs on to with the same profile, as in the case of Exchange accounts. Alternatively, the user can customize settings on each computer, as in the case of IMAP/POP accounts.

By default, Outlook uses weather data provided by MSN Weather. The Weather Bar supports third-party weather data web services that follow a defined protocol to communicate with Outlook. As long as a third-party weather data service supports this protocol, users can choose that weather data service to provide weather data in the Weather Bar. This article describes the protocol for third-party weather services to integrate with Outlook in the Weather Bar.

Weather Bar protocol

A user can specify a different weather data service for the Weather Bar, as long as that weather data service implements a web service that supports the following protocol to communicate with Outlook:

  1. The weather data service supports a base URL to a web service. For example, a Contoso Weather web service can have a base URL of https://service.contoso.com/data.aspx.

  2. The web service allows Outlook to append the following parameters to the base URL, to request a location code:

    • outputview=search:此參數表示要求是位置搜尋。

    • weasearchstr= city:此參數表示使用者想要氣象預報的位置,例如倫敦) (。

    • culture= LCID:此參數表示為該計算機上的使用者安裝的 Office 版本文化特性。 The LCID value is defined in [RFC4646] Tags for Identifying Languages

    • src=outlook:此參數表示 Outlook 是要求服務的用戶端應用程式。

    These parameters allow Outlook to take the location that the user is interested in and search for the associated location code as supported by the weather data service. The web service should respond to Outlook with a location code in XML that follows the Outlook Weather Location XML Schema. Figure 2 summarizes the web service request and response for a location code.

    圖 2: 位置代碼的 Web 服務要求和回應

    Weather location request and response

  3. The web service also allows Outlook to append the following parameters, to request forecast information for a location code:

    • wealocations= code:此參數中的 程式代碼 是 Outlook 從步驟 2 取得的位置代碼,對應至使用者感興趣的位置。

    • weadegreetype= degreetype:此參數會指定要針對溫度使用度量單位或單位度量單位。 針對度量指定 c,針對 degreetype 指定 f。 This parameter is optional and does not always exist in the web service request.

    • culture= LCID:此參數表示為該計算機上的使用者安裝的 Office 版本文化特性。 The LCID value is defined in [RFC4646] Tags for Identifying Languages

    • src=outlook:此參數表示 Outlook 是要求服務的用戶端應用程式。

    These parameters allow Outlook to take the location code returned from Step 2 and request the weather data service for the forecast. The web service should respond to Outlook with the corresponding weather data in XML that follows the Outlook Weather Information XML Schema. Figure 3 summarizes the web service request and response for weather data given a location code.

    圖 3: 氣象資訊的 Web 服務要求和回應

    Weather information request and response

Setting the Weather Bar to use a weather service

The administrator or power user can use the WeatherServiceUrl registry key to customize the Weather Bar to use a specific weather service. For example, if the base URL for a Contoso weather service is https://service.contoso.com/data.aspx, you can set the WeatherServiceUrl key to that URL.

The following table describes the WeatherServiceUrl key.

描述
Key
HKCU\Software\Microsoft\Office\15.0\Outlook\Options\Calendar
Value name
WeatherServiceUrl
Value type
REG_SZ
Default value
EMPTY_STRING
Description
URL to a weather data service.

Dependent conditions

Outlook 2013 displays the Weather Bar by default. This section describes a few reasons why the Weather Bar might not be visible.

Weather Bar is disabled

First, verify that Show weather on the calendar is selected in the Calendar tab in the Outlook Options dialog box.

Note that an administrator can also use Group Policy to disable the Weather Bar in Outlook 2013 entirely by setting the following key in the Windows registry:

描述
Key
HKCU\Software\Microsoft\Office\15.0\Outlook\Options\Calendar
Value name
DisableWeather
Value type
REG_DWORD
Default value
0
Description
A value of 0 enables the Weather Bar; any other value disables the Weather Bar.

If the Weather Bar feature has been disabled by Group Policy, the Calendar tab does not include the Show weather on the calendar check box. Consult with the administrator to turn the feature back on.

Office is disconnected from the Internet

Verify that Office is enabled to connect to the Internet—go to the Privacy options tab of the Trust Center in the Backstage view, and ensure that Allow Office to connect to the Internet is selected.

If the user has chosen to not receive updates for Office, the Weather Bar is also disabled.

An administrator can also use Group Policy to disable all online content, including the Weather Bar, by setting the following key in the Windows registry:

描述
Key
HKCU\Software\Microsoft\Office\15.0\Common\Internet
Value name
UseOnlineContent
Value type
REG_DWORD
Default value
2
Description
A value of 2 enables the Weather Bar; any other value disables the Weather Bar.

If the Weather Bar feature has been disabled by Group Policy, the Calendar tab does not include the Show weather on the calendar check box. Consult with the administrator to turn the feature back on.

Weather Bar example

This section shows an example of a Contoso Weather service that follows the preceding protocol to communicate with Outlook. For any location that the user selects, Outlook first gets a location code for that location from Contoso Weather, then using that location code, calls the Contoso Weather service to get the weather data.

基底 URL

Contoso Weather provides the following base URL for their weather data service:

https://service.contoso.com/data.aspx

Getting a location code

Outlook 會將上述步驟 2 中所述的參數附加至基底 URL,以取得地理位置 城市的位置代碼:

https://service.contoso.com/data.aspx?outputview=search&weasearchstr= city

As an example, if the user has selected Tokyo in the Weather Bar, Outlook uses the following URL to obtain the location code for Tokyo from Contoso Weather:

https://weather.service.contoso.com/data.aspx?outputview=search&weasearchstr=tokyo

Contoso Weather responds with the following XML to provide the location code for Tokyo. The XML conforms to the Outlook Weather Location XML Schema. Note that it is common for weather services to return data for more than one location (for example, if the selected location is a greater metropolitan area). In this example, the response for Tokyo includes two locations, each enclosed in a weather element. The corresponding location codes are as follows:

  • wc:JAXX0085的 weatherlocationname 屬性為 Tokyo, JPN

  • wc:10038604的 weatherlocationname 屬性為 Shinjuku-ku, Tokyo, Japan

<?xml version="1.0" ?>
<weatherdata>
  <weather weatherlocationcode="wc:JAXX0085" 
    weatherlocationname="Tokyo, JPN">
  </weather>
  <weather weatherlocationcode="wc:10038604" 
    weatherlocationname="Shinjuku-ku, JPN">
  </weather>
</weatherdata>

Getting weather information for a location code

After obtaining the location code for a location, Outlook appends the parameters described in Step 3 above to the base URL to obtain weather information for that location code.

https://service.contoso.com/data.aspx?wealocations = 代碼

As an example, if Outlook has obtained the location code wc:JAXX0085 from Contoso Weather for Tokyo, Outlook uses this location code in the following URL to get the weather information.

https://service.contoso.com/data.aspx?wealocations=wc:JAXX0085

Contoso Weather responds with the following XML to provide the weather information for the location code for Tokyo. The XML conforms to the Outlook Weather Information XML Schema.

<?xml version="1.0"?>
<weatherdata>
  <weather timezone="9" attribution="Data provided by Trey Research" 
    degreetype="F" imagerelativeurl="https://contoso.com/images/" 
    url="https://contoso.com/weather.aspx?eid=33568&amp;q=Tokyo-JPN" 
    weatherlocationname="Tokyo, JPN" 
    weatherlocationcode="wc:JAXX0085">
      <current winddisplay="9 mph NNW" windspeed="9" humidity="90" feelslike="44" 
        observationpoint="Tokyo" observationtime="06:00:00" 
        shortday="Sat" day="Saturday" date="2012-04-14" skytext="Rain" skycode="11" 
        temperature="48"/>
      <forecast shortday="Sat" day="Saturday" date="2012-04-14" precip="95" skytextday="Rain"
        skycodeday="11" high="55" low="47"/>
      <forecast shortday="Sun" day="Sunday" date="2012-04-15" precip="5" skytextday="Partly Cloudy" 
        skycodeday="30" high="65" low="43"/>
      <forecast shortday="Mon" day="Monday" date="2012-04-16" precip="5" skytextday="Partly Cloudy" 
        skycodeday="30" high="64" low="52"/>
      <forecast shortday="Tue" day="Tuesday" date="2012-04-17" precip="70" skytextday="Showers / Clear" 
        skycodeday="39" high="66" low="53"/>
      <forecast shortday="Wed" day="Wednesday" date="2012-04-18" precip="55" skytextday="Showers / Clear" 
        skycodeday="39" high="68" low="51"/>
  </weather>
</weatherdata>

Resetting Outlook to use MSN Weather

Even though Outlook uses MSN Weather by default, if a user has customized the Weather Bar to use a different weather service and subsequently wants to use MSN Weather again, the user can simply delete the WeatherServiceUrl key in the Windows Registry. Deleting that registry key resets Outlook to use MSN Weather.

總結

The Weather Bar in the Outlook calendar uses MSN Weather by default to provide the weather forecast for a specified location. Users can conveniently see weather information for the locations they care about. Third-party weather data services can also integrate with the Weather Bar by supporting the Outlook Weather Location XML Schema and Outlook Weather Information XML Schema and following a simple web service protocol with Outlook.

另請參閱