Example of sending scheduled text messages for free using PHP_php example

WBOY
Release: 2023-03-02 22:48:01
Original
1431 people have browsed it

Since Fetion currently does not have a development platform, the existing APIs are developed by third parties. It seems that they can send text messages by cracking WAP Fetion or 3G Fetion and simulating the behavior of the browser. In addition, there is an open source php Fetion sending class php-fetion on Google code. These Fetion interfaces facilitate the development of scheduled text messages.

Background: My mother is old and not well educated, but she needs to know the weather information every day before she can go to work in the field. Therefore, she cannot get the weather through the Internet, she can only get it through TV. So I thought about grabbing the weather information on the Internet and sending it to my mother through mobile phone text messages.

Problem: It is impossible for me to send weather text messages to my mother regularly every day, and the existing weather forecast subscription text messages cost money.

Solution:

Send SMS to mobile phone for free

Option 1: Use Fetion API

Since Fetion currently does not have a development platform, the existing APIs are developed by third parties. It seems that they can send text messages by cracking WAP Fetion or 3G Fetion and simulating the behavior of the browser. In addition, there is an open source php Fetion sending class php-fetion (http://code.google.com/p/php-fetion/) on Google Code. These Fetion interfaces facilitate the development of scheduled text messages.

The only disadvantage is that the third-party API is unstable and there is a risk of Fetion account leakage.

Here, I use the Fetion API provided by http://3.ibtf.sinaapp.com/ to send SMS messages.

The API only needs to provide the sender’s mobile phone number, password, recipient’s mobile phone number, and message content as url parameters. The only thing that needs attention is the problem of garbled Chinese characters (use gbk instead of utf-8 encoding, input Chinese garbled characters directly, and the phone will receive normal Chinese gbk encoding), which can be solved by using the iconv function or adding the parameter "&u=1".

Option 2: Use the SMS reminder function of 139 mailbox

139 mailbox is also a service of China Mobile, which provides the function of email and SMS reminder. As long as you set the email arrival notification in your mailbox, it will be OK. In addition to MMS, other long text messages, ordinary text messages, and hands-free text messages are free. Note that over time, both the outbox and the inbox should be cleared to avoid taking up too much space and affecting normal use.

Also, you only need to write a simple php script to send emails. Sina SAE also provides this Mail service. You can quickly send emails using the functions in the Mail service. The code is as follows:

<&#63;php 
$mail = new SaeMail(); 
$ret = $mail->quickSend(  
'收件人@139.com' ,  
'这是主题' , 
'这是正文' , 
'这是发件人邮箱' ,  
'这是发件人密码' , 
'这是smtp服务host' ,  
[这是smpt服务端口] );  
//发送失败时输出错误码和错误信息 
if ($ret === false) 
var_dump($mail->errno(),$mail->errmsg()); 
&#63;> 
Copy after login

The effect is as follows:

After the text message is successfully sent, it needs to be scheduled. Fortunately, Sina SAE provides Cron service. Cron service is a distributed timing service provided by SAE for developers. It is used to trigger specific actions of developers at regular intervals to meet needs such as scheduled ranking calculations. Cron settings are implemented through the App's config.yaml. As long as the user configures it in the config.yaml in the App directory according to the syntax format we provide, it will take effect after deployment.

Added Cron

Edit saetest/1/config.yaml and add a cron section. The config.yaml example is as follows:

name: saetest
version: 1
cron:
- description: cron test
url: mycron/test.php
schedule: $2 day of October 19:00
timezone: Beijing
- description: another cron test
url: mycron/another_test.php
schedule: every 10 minutes
timezone: Beijing

The above example describes two scheduled tasks: executing mycron/test.php at 19:00 on October 2 every year; executing mycron/another_test.php every 10 minutes

The above is the entire content of this article. I hope it will be helpful to everyone’s study. I also hope that everyone will support Script Home.

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!