PluginProbe
Event Post / 4.2
Event Post v4.2
6.1.1 6.1.0 6.0.1 6.0.0 5.12.0 trunk 3.9 4.0 4.2 4.3 4.4 4.5 5.0 5.1 5.10.0 5.10.1 5.10.2 5.10.3 5.10.4 5.11.0 5.11.1 5.2 5.5 5.6 5.6.1 All 46 releases
event-post / openweathermap.php

openweathermap.php in Event Post 4.2, at openweathermap.php

146 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 $EventPostWeather = new EventPostWeather();
5 /**
6 * Provides weather support thanks to OpenWeatherMap
7 * http://openweathermap.org
8 *
9 * License: Creative Commons (cc-by-sa)
10 * http://creativecommons.org/licenses/by-sa/2.0/.
11 *
12 *
13 * Get an API key
14 * http://openweathermap.org/appid#get
15 *
16 *
17 * # API examples
18 *
19 * ### current
20 * http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&APPID=XXXX
21 * return:
22 {"coord":{"lon":139,"lat":35},
23 "sys":{"country":"JP","sunrise":1369769524,"sunset":1369821049},
24 "weather":[{"id":804,"main":"clouds","description":"overcast clouds","icon":"04n"}],
25 "main":{"temp":289.5,"humidity":89,"pressure":1013,"temp_min":287.04,"temp_max":292.04},
26 "wind":{"speed":7.31,"deg":187.002},
27 "rain":{"3h":0},
28 "clouds":{"all":92},
29 "dt":1369824698,
30 "id":1851632,
31 "name":"Shuzenji",
32 "cod":200}
33 *
34 * ### forecast
35 * api.openweathermap.org/data/2.5/forecast?lat={lat}&lon={lon}&APPID=XXXX
36 * return:
37 {"city":{"id":1851632,"name":"Shuzenji",
38 "coord":{"lon":138.933334,"lat":34.966671},
39 "country":"JP",
40 "cod":"200",
41 "message":0.0045,
42 "cnt":38,
43 "list":[{
44 "dt":1406106000,
45 "main":{
46 "temp":298.77,
47 "temp_min":298.77,
48 "temp_max":298.774,
49 "pressure":1005.93,
50 "sea_level":1018.18,
51 "grnd_level":1005.93,
52 "humidity":87
53 "temp_kf":0.26},
54 "weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],
55 "clouds":{"all":88},
56 "wind":{"speed":5.71,"deg":229.501},
57 "sys":{"pod":"d"},
58 "dt_txt":"2014-07-23 09:00:00"}
59 ]}
60 *
61 * ### history
62 * http://api.openweathermap.org/data/2.5/history/city?lat={lat}&lon={lon}&type=hour&start={start}&end={end}&APPID=XXXX
63 * Parameters:
64 * lat, lon coordinates of the location of your interest
65 * type type of the call, keep this parameter in the API call as 'hour'
66 * start start date (unix time, UTC time zone), e.g. start=1369728000
67 * end end date (unix time, UTC time zone), e.g. end=1369789200
68 * cnt amount of returned data (one per hour, can be used instead of 'end') *
69 * return:
70 {"message":"","cod":"200","type":"tick","station_id":39419,"cnt":30,
71 "list":[
72 {"dt":1345291920,
73 "main":{"temp":291.55,"humidity":95,"pressure":1009.3},
74 "wind":{"speed":0,"gust":0.3},
75 "rain":{"1h":0.6,"today":2.7},
76 "calc":{"dewpoint":17.6} }
77 ]}
78 *
79 */
80 class EventPostWeather{
81 function __construct() {
82 // Hook into the plugin
83
84 // Alter objects
85 add_filter('eventpost_params', array(&$this, 'params'));
86 add_filter('eventpost_retreive', array(&$this, 'retreive'));
87
88 // Alter schema
89 add_filter('eventpost_item_scheme_entities', array(&$this, 'scheme_entities'));
90 add_filter('eventpost_item_scheme_values', array(&$this, 'scheme_values'));
91 add_filter('eventpost_list_shema', array(&$this, 'list_shema'));
92 }
93
94 /**
95 * PHP4 constructor
96 */
97 function EventPostWeather(){
98 $this->__construct();
99 }
100
101 /**
102 *
103 * @param array $params
104 * @return array
105 */
106 function params($params=array()){
107 return $params;
108 }
109 /**
110 *
111 * @param WP_Post $event
112 * @return WP_Post
113 */
114 function retreive($event){
115 return $event;
116 }
117 /**
118 *
119 * @param array $attr
120 * @return array
121 */
122 function scheme_entities($attr=array()){
123 return $attr;
124 }
125 /**
126 *
127 * @param array $values
128 * @return array
129 */
130 function scheme_values($values=array()){
131 return $values;
132 }
133 /**
134 *
135 * @param array $schema
136 * @return array
137 */
138 function list_shema($schema){
139 return $schema;
140 }
141
142
143 /**
144 * From here, methods intends to get datas
145 */
146 }