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, there are open-source php fetion Class php fetion on Googlecode. These Apsara stack APIs facilitate the development of scheduled text messages. "> <LINKhref =" http://www.php100.com//statics/st
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 a 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