Home >php教程 >php手册 >PHP调用调用TextMagic API发送短信

PHP调用调用TextMagic API发送短信

WBOY
WBOYOriginal
2016-06-13 09:37:531183browse

   PHP实现在线发短信,需要借助第三方API,以下代码就是调用了TextMagic API来实现发送短信的功能:

  view sourceprint?01

  02//引入TextMagic PHP库文件

  03require('textmagic-sms-api-php/TextMagicAPI.php');

  04$username = 'myusername';

  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发送短信模块类

Statement:
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