萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> PHP調用調用TextMagic API發送短信

PHP調用調用TextMagic API發送短信

   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發送短信模塊類

copyright © 萬盛學電腦網 all rights reserved