PHP Fetion notification weather forecast _ API version-PHP source code
Last Update:2018-03-24
Source: Internet
Author: User
PHP Fetion notification weather forecast _ API version /*************************************** ************************************/
/******************* PHP Apsara notification weather forecast _ API version ************* ******************/
/**************************** 2011-12-5 *********** *************************/
/*************************** Author: xiaogg *************************************/
/*************************** Version: 2.11 **************************************/
/******************** Http://www.bitefu.net ***************** ***************/
Header ("content-Type: text/html; charset = utf-8 ");
Function curl_file_get_contents ($ durl ){
If (function_exists ('curl _ setopt ')){
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ durl );
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 5 );
Curl_setopt ($ ch, CURLOPT_USERAGENT, _ USERAGENT _);
Curl_setopt ($ ch, CURLOPT_REFERER, _ REFERER _);
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
$ R = curl_exec ($ ch );
Curl_close ($ ch );
} Else if (function_exists ('File _ get_contents ')){
$ R = file_get_contents ($ durl );
} Else if (function_exists ('file ')){
$ R = file ($ durl); $ r = implode ('', $ r );
} Else {
$ R = "retrieving content failed ";
}
Return $ r;
}
// Delete spaces
Function wtrimall ($ str, $ type = 0)
{
$ Str = str_replace ("", "*-*", $ str );
$ Str = str_replace ("", "*-*", $ str );
$ Str = str_replace ("\ t", "*-*", $ str );
$ Str_s = str_replace ("\ n", "*-*", $ str );
$ Str = str_replace ("*-*", "", $ str_s );
If ($ type = 1) return $ str_s; else return $ str;
}
// Sort the keys and values of the array
Function wchangearray ($ str)
{
Return array_values (array_filter ($ str ));
}
Function wtext ($ city, $ weather_txt = "weahter.txt ")
{
$ Date = date ("Y-m-d"); $ arr = array (); $ arr ['Date'] = $ date;
If (! File_exists ($ weather_txt) {file_put_contents ($ weather_txt, serialize ($ arr ));}
$ Old = unserialize (file_get_contents ($ weather_txt ));
If ($ old ['Date']! = $ Date) {file_put_contents ($ weather_txt, serialize ($ arr ));}
If ($ old [$ city] & strlen ($ old [$ city])> 30) {return $ old [$ city];} else {
Switch ($ city)
{
Case "sjz": $ url = 'http: // www.weather.com.cn/weather/101090101.shtml'{}text= "Shijiazhuang"; break;
Case "yt": $ url = 'http: // www.weather.com.cn/weather/101090508.shtml'{}text= "Yutian"; break;
}
$ Lines_string = curl_file_get_contents ($ url );
$ Lines_string = explode (" ', '', $ Lines_string [1]), str_replace ('2 -->','', $ lines_string [2]), str_replace ('3 --> ', '', $ lines_string_3 [0]);
For ($ I = 0; $ I <count ($ lines_array); $ I ++)
{
$ Nowarray = strip_tags ($ lines_array [$ I]);
$ Datearray = explode ("day", $ nowarray); $ nowdata = wtrimall ($ datearray [0]); // get the date
$ Weather = explode ("daytime", $ nowarray); $ weather = explode ("nighttime", $ weather [1]);
$ Weather_bai = wtrimall (str_replace ("high temperature", "", $ weather [0]); $ weather_bai = str_replace ("℃", "degree", $ weather_bai ); // daytime weather
$ Weather_ye = wtrimall (str_replace ("Low temperature", "", $ weather [1]); $ weather_ye = str_replace ("℃", "degree", $ weather_ye ); // nighttime weather
$ Export ARR = wchangearray (explode ("\ r", $ weather_bai); $ yearr = wchangearray (explode ("\ r", $ weather_ye ));
$ Wtext [$ I] = trim ($ nowdata). "day ";
If ($ baiarr [0] ==$ yearr [0]) {$ wtext [$ I]. = $ baiarr [0];} else {$ wtext [$ I]. = $ baiarr [0]. "Turn ". $ yearr [0];} // add the weather to the return value
$ Wtext [$ I]. = $ baiarr [1]. "to". $ yearr [1]; // add the temperature to the return value
If ($ baiarr [2] ==$ yearr [2]) {$ wtext [$ I]. = $ baiarr [2];} else {$ wtext [$ I]. = str_replace ("wind", "", $ mongoarr [2]. "Turn ". $ yearr [2]); $ wtext [$ I]. = "wind";} // add the wind direction to the return value
If ($ baiarr [3]! = "Breeze") {$ wtext [$ I]. = $ javasarr [3];} // add the wind to the return value.
}
$ New = $ text. implode ("", $ wtext );
If (strlen ($ new) <30) {$ new = wtext ($ city );};
$ Newarr = array ($ city => $ new );
File_put_contents ($ weather_txt, serialize (array_unique (array_merge ($ old, $ newarr ))));
Return $ new;
}
}
// Start configuration
$ Phone_num = "150 *******"; // change it to your mobile phone number here;
$ Password = "*******"; // here, change it to your Apsara stack password.
$ Phone = "150 ******* | yt; 134 ******* | yt; 151 ******* | sjz; 150 ****** | sjz "; // here, change it to the phone number to be sent. Separate multiple numbers for sending. Note: You must be a friend of Apsara stack.
// The configuration is complete.
$ Tophone = explode (";", $ phone );
// Send SMS
For ($ I = 0; $ I $ Sys = explode ("|", $ tophone [$ I]);
$ Url = "http://www.bitefu.net/fetion? ";
$ Url. = "phone = ". $ phone_num. "& pwd = ". $ password. "& to = ". $ sys [0]. "& u = 1 & msg = ". wtext ($ sys [1]); // & u = 1 this parameter is added when garbled content is sent. if garbled content exists, remove this parameter.
File_get_contents ($ url );
} If ($ I = count ($ tophone) {sleep (100 );
?>