I am trying to send sms using cakephp-sms plugin
The documentation is quite clear and brief. I installed it using Composer in my app/Plugin
directory. I also installed xi-sms using composer. This was installed in the Vendor
directory. In my controller for sending sms. I included App::uses('CakeSms', 'Sms.Network/Sms')
and implemented an InfobipSmsTransport
class in the Sms/Lib/Network/Sms
. Below is my class
<?php
use Xi\Sms\Gateway\InfobipGateway;
App::uses('AbstractSmsTransport', 'Sms.Network/Sms');
class InfobipSmsTransport extends AbstractSmsTransport {
const INFOBIP_USER = 'XXXXX';
const INFOBIP_PASSWORD = 'XXXXXXX';
/**
*
* @param CakeSms $sms
* @return bool Success
*/
public function send(CakeSms $sms) {
$gw = new InfobipGateway(
self::INFOBIP_USER,
self::INFOBIP_PASSWORD
);
$service = new Xi\Sms\SmsService($gw);
$msg = new Xi\Sms\SmsMessage(
$sms->message(),
$sms->from(),
$sms->to()
);
$response = $service->send($msg);
return !empty($response);
}
}
?>
When I try to send an SMS however I get the following error
Class "InfobipSmsTransport" not found.
. I have no idea what am doing wrong? Any clues or suggestions are welcome.
The CakeSms class was not loading the plugin. This is the line of code where it was failing.
App::uses($transportClassname, $plugin . 'Network/Sms');
.
In my app/Config/sms.php
I just changed this 'transport' =>'Infobip'
to
'transport' =>'Sms.Infobip'
. The plugin is now being loaded properly and the class is found.