Developer extension to enable simple SMS sending via Magento for your custom modules.
Add the package to your require list:
"require": {
"studioforty9/twilio": "dev-master"
}
Add the repository to your project composer.json file:
"repositories": [
{"type": "vcs", "url": "https://github.com/studioForty9/twilio"}
],
$response = Mage::helper('studioforty9_twilio')->sendMesssage($to, $from, $message);
/* You can 'new' up an object like this:
$sms = new Studioforty9_Twilio_Model_Sms(array(
'accountId' => $accountId,
'authToken' => $authToken
));
*/
// Or use the typical Magento getModel approach
$sms = Mage::getModel('studioforty9_twilio/sms', array(
'accountId' => $accountId,
'authToken' => $authToken
));
$response = $sms->setTo('+12345678901')
->setFrom('+12345678901')
->setBody('Your message')
->send();
If you need to use a custom HTTP client for any reason (we use Varien_Http_Client
by default) - you can inject an intance of Zend_Http_Client
into the Studioforty9_Twilio_Model_Sms
class via the $config
array.
$client = new Zend_Http_Client();
$sms = Mage::getModel('studioforty9_twilio/sms', array(
'accountId' => $accountId,
'authToken' => $authToken,
'client' => $client
));
Media SMS is currently unsupported.
BSD 3 Clause see LICENCE file