您需要一个 TextMagic 帐户 并下载他们在注册后提供的 PHP 帮助程序。
// Include the TextMagic PHP lib
require('textmagic-sms-api-php/TextMagicAPI.php');
// Set the username and password information
$username = 'myusername';
$password = 'mypassword';
// Create a new instance of TM
$router = new TextMagicAPI(array(
'username' => $username,
'password' => $password
));
// Send a text message to '999-123-4567'
$result = $router->send('Wake up!', array(9991234567), true);
// result: Result is: Array ( [messages] => Array ( [19896128] => 9991234567 ) [sent_text] => Wake up! [parts_count] => 1 )
嗨,Chris,不错。首先感谢您发表如此有见地的文章,但如果我正在使用框架,例如 CakePHP,这种方法是否有效?
Rishi:使用 CakePHP 或 Zend 等工具执行此操作的“正确”方法是将 TextMagic API 设置为第三方库。但是,即使像 Chris 在这里演示的那样包含它也能工作,是的。
无论是否使用框架,归根结底它仍然是 PHP。;)
谢谢 Vincent :-)
请问能否提供发送短信的实际/完整代码……
至少可以说,您所有的东西都非常令人印象深刻.. 对于短信,您还可以免费使用 MailUtils 和 SSMTP。
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
echo “AuthUser=$AuthUser” >> /etc/ssmtp/ssmtp.conf
echo “AuthPass=$AuthPass” >> /etc/ssmtp/ssmtp.conf
echo “FromLineOverride=YES” >> /etc/ssmtp/ssmtp.conf
echo “mailhub=smtp.gmail.com:587” >> /etc/ssmtp/ssmtp.conf
echo “useSTARTTLS=YES” >> /etc/ssmtp/ssmtp.conf
echo $message | mail -s “$SUBJECT” $NUMBER
这太棒了,我们使用过 http://notifynotify.com 来捕获电话号码,然后使用他们的平台发送出去。