To implement online text messaging in PHP, you need to use a third-party API. The following code calls the TextMagic API to implement the function of sending text messages:
view sourceprint?01
02//Introducing TextMagic PHP library file
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//Send a message to '222-345-5678'
11$result = $router->send('Wake up!', array(2223455678), true);
12//Result (official information): Array ( [messages] => Array ( [19896128] => 9991234567 ) [sent_text] => Wake up! [parts_count] => 1 )
13?>
If you don’t have the TextMagic API class library, you can download it here: TextMagic-SMS-API PHP SMS module class