Instances that use PHP to send scheduled messages for free, and instances that use php to send SMS messages

Source: Internet
Author: User

Instances that use PHP to send scheduled messages for free, and instances that use php to send SMS messages

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 the open-source php fetion class php-fetion. These Apsara stack APIs facilitate the development of Scheduled text messages.

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.

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.

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:

<? Php $ 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]); // if ($ ret = false) var_dump ($ mail-> errno (), $ mail-> errmsg ();?>

The effect is as follows:

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.

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.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.