Use PHP free to send timed SMS (for weather forecasts, timed reminders, SMS blessings, etc.)

Source: Internet
Author: User
Send timed text messages free of charge using PHP (for weather forecasts, timed reminders, SMS blessings, etc.)

Send timed text messages free of charge with PHP

background: mom is old, not high education, but need to know the weather information to work in the fields, you can not get the weather through the Internet, only through the TV. So I was thinking about crawling the weather information on the Internet and sending it to my mom via SMS.

problem: It is impossible for me to send daily weather messages to my mother on a regular basis, and the existing weather forecast is for money.


    • send SMS to phone for free

Scenario 1: Using the Fetion API

Since Fetion currently has no development platform, the existing API is a third-party development, seemingly by cracking WAP fetion or 3G fetion, simulating the behavior of the browser to send text messages. In addition, Google Code on the open source PHP fetion send class Php-fetion ( These fetion interfaces facilitate the development of timed SMS.

The only drawback is that third-party APIs are unstable and there is a risk of fetion account leaks.

Here, I use the Fetion API provided by send SMS messages. The station itself hangs on the Sina SAE, the source code can be found in (the download address is provided inside).

The API only needs to provide the sender's mobile phone number, password, recipient mobile phone number, message content as a URL parameter. The only thing to note is the Chinese garbled problem (using GBK instead of UTF-8 encoding, directly input Chinese garbled, input Chinese GBK encoded phone to receive the normal), you can use the Iconv function or add the parameter "&u=1" to solve.

Example: calling the Free API mobile phone number &pwd= fetion password &to= receive phone number (must be fetion friend or your own phone number) &msg= message content &u=1 (solve garbled problem)

Scenario 2: Use the SMS Alert feature for 139 mailboxes

139 e-mail is also a business of China Mobile, providing the function of SMS alert. As long as in the mailbox to set the mail arrival notice on the OK, in addition to MMS, other short letter, ordinary text messages, hands-free text messages are complimentary. Note that the time is long, the Outbox and the Inbox should be cleared, so as not to occupy too much space and affect the normal use.

In addition, you only need to write a Simple mail-sent PHP script. Sina SAE also provides this mail service. Using the functions in the Mail service, you can quickly send messages with the following code:

$mail = new Saemail ();

$ret = $mail->quicksend (

' Recipient ',

' This is the subject ',

' This is the text ',

' This is the sender's mailbox ',

' This is the sender's password ',

' This is the SMTP Service host ',

[This is the Smpt service port]);

Output error codes and error messages when sending fails

if ($ret = = = False)

Var_dump ($mail->errno (), $mail->errmsg ());


For more information, refer to the Mail Service API documentation

The effect is as follows:

    • timed Send function

Once the text message is sent successfully, it needs to be timed. Fortunately Sina SAE offers a cron service. The cron service is a distributed timing service provided by the SAE for developers to periodically trigger specific actions by developers to meet such needs as the scheduled calculation of leaderboards. Cron settings are implemented through the Config.yaml of the app, as long as the user is configured in the Config.yaml in the app directory according to our provided syntax format, which will take effect after deployment.

Example : Detailed tutorial Reference API documentation

Increase Cron

Edit Saetest/1/config.yaml, add cron segment, Config.yaml examples are as follows:




-Description:cron Test


Schedule: $ October 19:00


-Description:another cron Test


Schedule:every mins


The above example describes two scheduled tasks: Execute mycron/test.php on October 2 19 o'clock each year and execute mycron/another_test.php every 10 minutes

    • PHP Weather Crawl

There are many places on the Internet that provide weather information, such as SINA, China weather NET, etc., there are related APIs and open source code. This is relatively simple, not to elaborate. Of course, the above mentioned Fetion API site the source code is also on the weather to grab the codes, can learn from.

    • Implement

1 Floor Jaylongli5 hours ago
In fact, the software comes with the weather notification function, such as fetion can set up a timed weather notification.
Re: xiangshimoni3 hours ago
reply Jaylonglin seems to be an enterprise version of the function bar, to charge
  • 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: 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.