先上效果图: 大概需要准备的: 1、一个公网服务器或者本地服务器也可以,能通互联网。 2、一个天气API接口 3、一个发短信的API接口 处理逻辑: 1、shellcurl天气API接口,获取结果; 2、解析结果(unicode转码需要用到native2asciiJDK里面的); 3、组装发短信的报文; 4、调用发短信的API发送报文。 5、可以视情况编写定时任务,crontab。 附代码:!binbash。。bashprofile。etcprofilecdhomeCYTpwdcurlshttp:api。yytianqi。comobserve?city37。73565,112。56878key你的天气tokennative2asciiencodingUTF8reversetianqishikaung。txtsleep5s天气实况城市名称cityNamecattianqishikaung。txtseds,ggrepwcityNamesedsgseds:gawk{printf2}天气现象tqcattianqishikaung。txtseds,ggrepwtqsedsgseds:gawk{printf2}当前风向fxcattianqishikaung。txtseds,ggrepwfxsedsgseds:gawk{printf2}当前风力flcattianqishikaung。txtseds,ggrepwflsedsgseds:gawk{printf2}相对湿度sdcattianqishikaung。txtseds,ggrepwsdsedsgseds:gawk{printf2}seds}}g当前气温qwcattianqishikaung。txtseds,ggrepwqwsedsgseds:gawk{printf2}DQTQechocityNametq,fxfl,当前气温为qw,相对湿度为sd。echo{DQTQ}curlshttp:api。yytianqi。comforecast7d?city37。73565,112。56878key你的天气tokennative2asciiencodingUTF8reversetianqiyubao。txtsleep5sdate1cattianqiyubao。txtseds,ggrepwdatehead2awkNR2sedsgseds:gawk{print2}seds}g白天天气tq1cattianqiyubao。txtseds,ggrepwtq1head2awkNR2sedsgseds:gawk{print2}seds}g白天气温qw1cattianqiyubao。txtseds,ggrepwqw1head2awkNR2sedsgseds:gawk{print2}seds}g白天风向fx1cattianqiyubao。txtseds,ggrepwfx1head2awkNR2sedsgseds:gawk{print2}seds}g白天风力fl1cattianqiyubao。txtseds,ggrepwfl1head2awkNR2sedsgseds:gawk{print2}seds}g夜间天气tq2cattianqiyubao。txtseds,ggrepwtq2head2awkNR2sedsgseds:gawk{print3}cattianqiyubao。txtseds,ggrepwtq2awkNR2sedsgseds{gseds:gawk{print2}夜间气温qw2cattianqiyubao。txtseds,ggrepwqw2head2awkNR2sedsgseds:gawk{print2}seds}g夜间风向fx2cattianqiyubao。txtseds,ggrepwfx2head2awkNR2sedsgseds:gawk{print2}seds}g夜间风力fl2cattianqiyubao。txtseds,ggrepwfl2head2awkNR2sedsgseds:gawk{print2}seds}gMTTQecho明日date1白天tq1,气温为qw1,fx1fl1,夜间tq2,气温为qw2,fx2fl2。echo{MTTQ}天气指数curlXGEThttp:api。yytianqi。comweatherindex?city37。73565,112。56878key你的天气tokennative2asciiencodingUTF8reversetianqizhishu。txtsleep5s穿衣指数cyzhcattianqizhishu。txtseds,gsedsgseds:ggrep穿greplongDescsedslongDescgseds}gechoMTTQecho{DQTQ}{cyzh}{MTTQ}mobile你的手机号curlhttp:1111。cnHXXXXXXXXXXXX0001Hcontenttype:applicationjsond{txnBodyCom:{MSGSMSMBLPHNO:{mobile},MSGSMSCNTNT:{DQTQ}{cyzh}{MTTQ}}}