php实现在线发短信,需要借助第三方api,以下代码就是调用了textmagic api来实现发送短信的功能:
view sourceprint?01
02//引入TextMagic PHP库文件
03require('textmagic-sms-api-php/TextMagicAPI.php');
04$username = 'myusername';
立即学习“PHP免费学习笔记(深入)”;
05$password = 'mypassword';
06$router = new TextMagicAPI(array(
07 'username' => $username,
08 'password' => $password
09));
10//发送一条信息到'222-345-5678'
11$result = $router->send('Wake up!', array(2223455678), true);
12//结果(官方资料): Array ( [messages] => Array ( [19896128] => 9991234567 ) [sent_text] => Wake up! [parts_count] => 1 )
13?>
若没有TextMagic API类库的可在这里下载:TextMagic-SMS-API PHP发送短信模块类
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号