Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Monalisa Sahu
Weather Portlet
28. Februar 2012 04:39
Antwort

Monalisa Sahu

Rang: New Member

Nachrichten: 2

Eintrittsdatum: 28. Februar 2012

Neue Beiträge

Can anybody send me weather portlet
David H Nebinger
RE: Weather Portlet
28. Februar 2012 05:08
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11056

Eintrittsdatum: 1. September 2006

Neue Beiträge

Whatever you guys are working on, you should share notes.

Review all of the other recent posts on the weather portlet: where to get it, how to deploy it, how to configure it, and why invalid params result in blank screen.
Monalisa Sahu
RE: Weather Portlet
28. Februar 2012 05:40
Antwort

Monalisa Sahu

Rang: New Member

Nachrichten: 2

Eintrittsdatum: 28. Februar 2012

Neue Beiträge

where should i put the war file of weather portlet in order to deploy it
David H Nebinger
RE: Weather Portlet
28. Februar 2012 05:44
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11056

Eintrittsdatum: 1. September 2006

Neue Beiträge

Again, this has all been covered in recent weeks as your friends have been doing the same things.

Search the forum to find the info.
Dave Weitzel
RE: Weather Portlet
6. Dezember 2012 13:02
Antwort

Dave Weitzel

Rang: Regular Member

Nachrichten: 203

Eintrittsdatum: 18. November 2009

Neue Beiträge

Google has now stopped providing the weather api used in the portlet so it is not usable until updated to a new API
Hitoshi Ozawa
RE: Weather Portlet
6. Dezember 2012 14:17
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7949

Eintrittsdatum: 23. März 2010

Neue Beiträge

It's already been fixed.

http://issues.liferay.com/browse/LPS-29542
Jitendra Rajput
RE: Weather Portlet
6. Dezember 2012 21:45
Antwort

Jitendra Rajput

Rang: Liferay Master

Nachrichten: 858

Eintrittsdatum: 7. Januar 2011

Neue Beiträge

If you want to check code then look into WeatherWebCacheItem.java .
Old code with google API was like this

 1
 2public Object convert(String key) throws WebCacheException {
 3        Weather weather = null;
 4
 5        try {
 6            String text = HtmlUtil.stripComments(HttpUtil.URLtoString(
 7                "https://www.google.com/ig/api?weather=" +
 8                    HttpUtil.encodeURL(_zip)));
 9
10            int x = text.indexOf("temp_f data");
11
12            x = text.indexOf("\"", x) + 1;
13
14            int y = text.indexOf("\"", x);
15
16            float temperature = GetterUtil.getFloat(text.substring(x, y));
17
18            x = text.indexOf("/images", x);
19            y = text.indexOf("\"", x);
20
21            String iconURL = "https://www.google.com" + text.substring(x, y);
22
23            weather = new Weather(_zip, iconURL, temperature);
24        }
25        catch (Exception e) {
26            throw new WebCacheException(_zip);
27        }
28
29        return weather;
30    }


And new code with API change

 1
 2 public Object convert(String key) throws WebCacheException {
 3        Weather weather = null;
 4
 5        try {
 6            StringBundler sb = new StringBundler(5);
 7
 8            sb.append("http://free.worldweatheronline.com/feed/weather.ashx?key=");
 9            sb.append(WeatherPropsUtil.get("world.weather.online.api.key"));
10            sb.append("&q=");
11            sb.append(HttpUtil.encodeURL(zipName));
12            sb.append("&format=xml");
13            
14            String xml = HtmlUtil.stripComments(HttpUtil.URLtoString(sb.toString()));
15
16            Document document = SAXReaderUtil.read(xml);
17
18            Element rootElement = document.getRootElement();
19
20            Element currentConditionElement = rootElement.element(
21                "current_condition");
22
23            Element temperatureElement = currentConditionElement.element("temp_F");
24
25            float temperature = GetterUtil.getFloat(temperatureElement.getData());
26
27            Element iconElement = currentConditionElement.element("weatherIconUrl");
28
29            String iconURL = iconElement.getText();
30
31            weather = new Weather(zipName, iconURL, temperature);
32        }
33        catch (Exception e) {
34            throw new WebCacheException(zipName);
35        }
36
37        return weather;
38    }