1
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
2
+ <?php
3
+ //带伞提醒 Ver.2
4
+ require 'config.php ' ;
5
+ //对json格式的字符串进行编码
6
+ $ arr = json_decode ($ str ,TRUE );
7
+ //城市名
8
+ $ city = ($ arr ['HeWeather6 ' ]['0 ' ]['basic ' ]['location ' ]);
9
+ $ motd = "亦可赛艇! " ;
10
+ foreach ($ arr ['HeWeather6 ' ][0 ]['daily_forecast ' ]as $ key => $ val )
11
+ {
12
+ $ data [] = "日期: " .$ val ['date ' ];
13
+ $ txt_d [] = "{$ val ['cond_txt_d ' ]}" ;
14
+ $ txt_n [] = "{$ val ['cond_txt_n ' ]}" ;
15
+ $ winds [] = "{$ val ['wind_dir ' ]}" ;
16
+ $ tmps [] = "{$ val ['tmp_max ' ]}~ {$ val ['tmp_min ' ]}℃ " ;
17
+ }
18
+ if ($ txt_d [0 ] == $ txt_n [0 ]){
19
+ $ weather0 = $ txt_d [0 ];
20
+ }else {
21
+ $ weather0 = $ txt_d [0 ]."转 " .$ txt_n [0 ];
22
+ };
23
+
24
+ if ($ txt_d [1 ] == $ txt_n [1 ]){
25
+ $ weather1 = $ txt_n [1 ];
26
+ }else {
27
+ $ weather1 = $ txt_d [1 ]."转 " .$ txt_n [1 ];
28
+ };
29
+
30
+ if ($ txt_d [2 ] == $ txt_n [2 ]){
31
+ $ weather2 = $ txt_n [2 ];
32
+ }else {
33
+ $ weather2 = $ txt_d [2 ]."转 " .$ txt_n [2 ];
34
+ };
35
+
36
+ if (strstr ($ weather0 ,"雨 " )){
37
+ $ need = "需要带伞 " ;
38
+ $ today = "今天会下雨哦 " ;
39
+ }else {
40
+ $ need = "不需要带伞 " ;
41
+ $ today = "今天是个好天气 " ;
42
+ }
43
+ $ weather0 = $ weather0 .", " .$ winds [0 ].", " .$ tmps [0 ];
44
+ $ weather1 = $ weather1 .", " .$ winds [1 ].", " .$ tmps [1 ];
45
+ $ weather2 = $ weather2 .", " .$ winds [2 ].", " .$ tmps [2 ];
46
+
47
+
48
+ $ mai = <<<LABELSS
49
+ <style type="text/css">
50
+ img {
51
+ max-width: 100%;
52
+ }
53
+ body {
54
+ -webkit-font-smoothing: antialiased;
55
+ -webkit-text-size-adjust: none;
56
+ width: 100% !important;
57
+
58
+ line-height: 1.6em;
59
+ }
60
+ body {
61
+ background-color: #f6f6f6;
62
+ }
63
+ @media only screen and (max-width: 640px) {
64
+ body {
65
+ padding: 0 !important;
66
+ }
67
+ h1 {
68
+ font-weight: 800 !important;
69
+ margin: 20px 0 5px !important;
70
+ }
71
+ h2 {
72
+ font-weight: 800 !important;
73
+ margin: 20px 0 5px !important;
74
+ }
75
+ h3 {
76
+ font-weight: 800 !important;
77
+ margin: 20px 0 5px !important;
78
+ }
79
+ h4 {
80
+ font-weight: 800 !important;
81
+ margin: 20px 0 5px !important;
82
+ }
83
+ h1 {
84
+ font-size: 22px !important;
85
+ }
86
+ h2 {
87
+ font-size: 18px !important;
88
+ }
89
+ h3 {
90
+ font-size: 16px !important;
91
+ }
92
+ .container {
93
+ padding: 0 !important;
94
+ width: 100% !important;
95
+ }
96
+ .content {
97
+ padding: 0 !important;
98
+ }
99
+ .content-wrap {
100
+ padding: 10px !important;
101
+ }
102
+ .invoice {
103
+ width: 100% !important;
104
+ }
105
+ }
106
+ </style>
107
+
108
+ <table class="body-wrap" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;" bgcolor="#f6f6f6">
109
+ <tbody><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
110
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top"></td>
111
+ <td class="container" width="600" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto;" valign="top">
112
+ <div class="content" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;">
113
+ <table class="main" width="100%" cellpadding="0" cellspacing="0" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;" bgcolor="#fff">
114
+ <tbody><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
115
+ <td class="content-wrap aligncenter" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 20px;" align="center" valign="top">
116
+ <table width="100%" cellpadding="0" cellspacing="0" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
117
+ <tbody><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
118
+ <td class="content-block" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
119
+ <h1 class="aligncenter" style="font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; box-sizing: border-box; font-size: 32px; color: #000; line-height: 1.2em; font-weight: 500; text-align: center; margin: 40px 0 0;" align="center"></h1>
120
+ </td>
121
+ </tr>
122
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
123
+ <td class="content-block" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
124
+ <h2 class="aligncenter" style="font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; box-sizing: border-box; font-size: 24px; color: #000; line-height: 1.2em; font-weight: 400; text-align: center; margin: 40px 0 0;" align="center"> {$ today }</h2>
125
+ <h4 class="aligncenter" style="font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; box-sizing: border-box; font-size: 24px; color: #000; line-height: 1.2em; font-weight: 400; text-align: center; margin: 40px 0 0;" align="center"> {$ city }</h4>
126
+ </td>
127
+ </tr>
128
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
129
+ <td class="content-block aligncenter" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 0 0 20px;" align="center" valign="top">
130
+ <table class="invoice" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; text-align: left; width: 80%; margin: 40px auto;">
131
+ <tbody><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
132
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 5px 0;" valign="top">Hi, {$ userid }<br style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">邮箱: {$ usermail }</td>
133
+ </tr>
134
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
135
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 5px 0;" valign="top">
136
+ <table class="invoice-items" cellpadding="0" cellspacing="0" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; margin: 0;">
137
+ <tbody><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
138
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" valign="top">今天的天气是:</td>
139
+ <td class="alignright" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: right; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" align="right" valign="top"> {$ weather0 }</td>
140
+ </tr>
141
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
142
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" valign="top"> 明天的天气是:</td>
143
+ <td class="alignright" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: right; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" align="right" valign="top"> {$ weather1 }</td>
144
+ </tr>
145
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
146
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" valign="top">后天的天气是:</td>
147
+ <td class="alignright" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: right; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" align="right" valign="top"> {$ weather2 }</td>
148
+ </tr>
149
+
150
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
151
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" valign="top">是否需要带伞?</td>
152
+ <td class="alignright" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: right; border-top-width: 1px; border-top-color: #eee; border-top-style: solid; margin: 0; padding: 5px 0;" align="right" valign="top"> {$ need }</td>
153
+ </tr>
154
+
155
+
156
+ </tbody></table>
157
+ </td>
158
+ </tr>
159
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
160
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 5px 0;" valign="top"> {$ motd }</td>
161
+ </tr>
162
+
163
+ </tbody></table>
164
+ </td>
165
+ </tr>
166
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
167
+ <td class="content-block aligncenter" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 0 0 20px;" align="center" valign="top">
168
+ <a href="" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #348eda; text-decoration: underline; margin: 0;"></a>
169
+ </td>
170
+ </tr>
171
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
172
+ <td class="content-block aligncenter" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 0 0 20px;" align="center" valign="top"><a href=" {$ link }"> {$ appname }</a></td>
173
+ </tr>
174
+ </tbody></table>
175
+ </td>
176
+ </tr>
177
+ </tbody></table>
178
+ <div class="footer" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; clear: both; color: #999; margin: 0; padding: 20px;">
179
+ <table width="100%" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
180
+ <tbody><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
181
+ </tr>
182
+ </tbody></table>
183
+ </div>
184
+ </div>
185
+ </td>
186
+ <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top"></td>
187
+ </tr>
188
+ </tbody></table>
189
+ LABELSS ;
190
+
191
+ if (strstr ($ weather0 ,"雨 " )){
192
+ $ need = "需要带伞 " ;
193
+ $ mailto =$ usermail ; //收件人
194
+ $ subject ="今日有雨,注意带伞 " ; //邮件主题
195
+ $ body =$ mai ; //邮件内容
196
+ sendmailto ($ mailto ,$ subject ,$ body );
197
+ }
198
+ else
199
+ {
200
+ $ need = "不需要带伞 " ;
201
+ $ mailto =$ usermail ; //收件人
202
+ $ subject ="今天是个好天气 " ; //邮件主题
203
+ $ body =$ mai ; //邮件内容
204
+ sendmailto ($ mailto ,$ subject ,$ body );
205
+ };
206
+
207
+
208
+ print_r ($ mai );
209
+
210
+ ?>
0 commit comments