Use Feixin to send a weather forecast text message to yourself (which has just been written and is effective)-PHP source code

Source: Internet
Author: User
Use Feixin to send a weather forecast text message to yourself (which has just been written and is effective) php code

 Geturlfile ($ url); // get content $ start ='

'; $ End ='

'; $ Content = $ gather-> get_sub_content ($ html, $ start, $ end); $ text = substr (SpHtml2Text ($ content), 42 ); // load the flying mail class (search for the class itself on the Internet) require '. /lib/PHPFetion. php '; // mobile phone number, fetion password $ fetion = new PHPFetion ('xxxxxxxxxxxxxxxx', 'xxxxxxxx'); // sent number, and weather forecast information $ fetion-> send ('20140901', $ text); echo 'OK! Sent successfully! ';/*** Collection class */class gather {public $ pagestring = ''; private $ db; function _ construct () {global $ db; $ this-> db = $ db;} function geturlfile ($ url) {$ url = trim ($ url); $ content = ''; if (extension_loaded ('curl') {$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ ch, CURLOPT_HEADER, 0); $ co Ntent = curl_exec ($ ch); curl_close ($ ch);} else {$ content = file_get_contents ($ url);} return trim ($ content );} function s ($ code) {preg_match_all ('/"\'] +) [" | \ ']? \ S * [^>] *> ([^>] +) <\/a>/is ', $ code, $ arr ); return array ('name' => $ arr [2], 'URL' => $ arr [1]);} function get_sub_content ($ str, $ start, $ end) {$ start = trim ($ start); $ end = trim ($ end); if ($ start = ''| $ end = '') {return $ str ;}$ str = explode ($ start, $ str); $ str = explode ($ end, $ str [1]); return $ str [0];} function vd ($ var) {echo"

\ R \ n "; echo"

\r\n";        var_dump($var);        echo "\r\n
\ R \ n "; echo"

";}}// Convert html to textfunction SpHtml2Text ($ str) {$ str = preg_replace ("/ | | /IsU "," ", $ str); $ alltext =" "; $ start = 1; for ($ I = 0; $ I ") {$ Start = 1;} else if ($ start = 1) {if ($ str [$ I] =" <") {$ start = 0; $ alltext. = "";} else if (ord ($ str [$ I])> 31) {$ alltext. = $ str [$ I] ;}}$ alltext = str_replace ("", "", $ alltext); $ alltext = preg_replace ("/& ([^; &] *) (; | &)/"," ", $ alltext); $ alltext = preg_replace ("/[] +/s "," ", $ alltext ); return $ alltext;}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.