Use PhP to send scheduled text messages for free (for weather forecasts, scheduled reminders, SMS greetings, etc)

Source: Internet
Author: User
Use PhP to send scheduled text messages (for weather forecasts, scheduled reminders, SMS greetings, and so on) for free. use PhP to send scheduled text messages for free & nbsp; background: old mom, not highly educated, however, you need to know the weather information every day before you can go to work, so you cannot get the weather through the Internet, but you can only get the weather through TV. As a result, I thought about how to capture the weather information on the internet and send it to my mom via a text message. Problem: It is impossible for me to send regular text messages to my mom on a daily basis using PhP for free (used for weather forecasts, scheduled reminders, SMS greetings, etc)

Use PhP to send scheduled messages for free

 

Background:When my mom is older, she is not highly educated. but she needs to know the weather information every day before she can go to work, so she cannot get the weather through the Internet and can only get the weather through TV. As a result, I thought about how to capture the weather information on the internet and send it to my mom via a text message.

Problem:It is impossible for me to send a weather text message to my mom on a regular basis every day. The current weather forecast subscription text message also requires money.

Solution:

  •  Send SMS to mobile phone for free

Solution 1: Use the Apsara stack API

Currently, Apsara stack does not have a development platform, and the existing APIs are developed by a third party. it seems that you have cracked WAP or 3G Apsara stack to simulate browser behavior to send text messages. In addition, Google code has open source php fetion Class php fetion (http://code.google.com/p/php-fetion ). These Apsara stack APIs facilitate the development of scheduled text messages.

The only drawback is that the third-party API is unstable and there is a risk that the Apsara stack account is leaked.

Here, I am sending a text message using the API feature of http://3.ibtf.sinaapp.com/shenzhen. The station itself is mounted on Sina SAEs. the source code can be found at http://www.oschina.net/code/snippet_202258_9754( which is provided ).

This API provides the sender's mobile phone number, password, receiver's mobile phone number, and message content as url parameters. The only thing to note is Chinese garbled text (using gbk instead of UTF-8 encoding, entering Chinese garbled text directly, and inputting Chinese gbk encoding on the mobile phone is normal ), you can use the iconv function or add the parameter "& u = 1.

Example:Call free API

Http://2.ibtf.sinaapp.com /? Phone = mobile phone number & pwd = Feixin password & to = receiving mobile phone number (must be a friend of Feixin or your own mobile phone number) & msg = message content & u = 1 (solve the garbled problem)

Solution 2: Use the SMS reminder function of email 139

139 mailbox is also a service of China Mobile, and provides the function of email text message reminder. You only need to set the email arrival notification in your mailbox. in addition to MMS, other long messages, common text messages, and hands-free text messages are free of charge. Note that after a long time, the sender and inbox must be cleared to avoid occupying too much space and affecting normal use.

In addition, you only need to write a simple php script for sending emails. Sina SAE also provides this Mail service. You can use the functions in the Mail service to send emails quickly. the code is as follows:

$ Mail = new SaeMail ();

$ Ret = $ mail-> quickSend (

'Recipient @ 139.com ',

'This is the topic ',

'This is the body ',

'This is the sender mailbox ',

'This is the sender 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, see the Mail service API documentation http://apidoc.sinaapp.com/sae/saemail.html.

The effect is as follows:

 



  •  Timed sending

After the text message is sent successfully, you need to set the time. Fortunately, Sina SAE provides the Cron service. The Cron service is a distributed timing service provided by SAE for developers. it is used to trigger specific actions of developers on a regular basis to meet requirements such as regular computing rankings. Cron is set through App config. yaml, as long as the user is in the config. yaml is configured according to the syntax format provided by us. after deployment, it will take effect.

Example: Detailed tutorial reference API documentation http://sae.sina.com.cn /? M = devcenter & catId = 195.

Add Cron

Edit saetest/1/config. yaml and add the cron segment. the example of config. yaml is as follows:

Name: saetest

Version: 1

Cron:

-Description: cron test

Url: mycron/test. php

Schedule: $2 day of October

Timezone: Beijing

-Description: another cron test

Url: mycron/another_test.php

Schedule: every 10 mins

Timezone: Beijing

The preceding example describes two scheduled tasks: execute mycron/test. php at on January 1, October 2, and execute mycron/another_test.php every 10 minutes.

  • PHP weather capture

There are many places on the Internet that provide weather information, such as Sina and www.weather.com, as well as related APIs and open-source code. This is not detailed. Of course, the source code of the above-mentioned Apsara API site http://3.ibtf.sinaapp.com/also has a weather capture code, which can be used for authentication.

  •  Implementation




1 floor jaylongli5 hours ago
In fact, the software comes with the weather notification function. for example, Apsara can set a scheduled weather notification.
Re: xiangshimoni3 hour ago
The reply to jaylonglin seems to be a feature of the Enterprise edition, which is charged.

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.