PHP code example of fotografde / cakephp-sms
1. Go to this page and download the library: Download fotografde/cakephp-sms library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fotografde / cakephp-sms example snippets php
App::uses('CakeSms', 'Sms.Network/Sms');
$CakeSms = new CakeSms('default');
$CakeSms->to('+491234567890');
$CakeSms->from('+841234567890');
$CakeSms->send('Hello world!');
php
CakePlugin::load('Sms');
php
class SmsConfig {
public $default = array(
'transport' => 'Clickatell', // will use class ClickatellSmsTransport
);
}
php
/**
* Send SMS through SMS provider Clickatell
*/
use Xi\Sms\Gateway\ClickatellGateway;
App::uses('AbstractSmsTransport', 'Sms.Network/Sms');
class ClickatellSmsTransport extends AbstractSmsTransport {
const CLICKATELL_API_ID = 'XXXX';
const CLICKATELL_USER = 'YYYY';
const CLICKATELL_PASSWORD = 'ZZZZ';
/**
* Sends an SMS Through Clickatell
* We could also consider using this library: http://github.com/arcturial/clickatell
*
* @param CakeSms $sms
* @return bool Success
*/
public function send(CakeSms $sms) {
$gw = new ClickatellGateway(
self::CLICKATELL_API_ID,
self::CLICKATELL_USER,
self::CLICKATELL_PASSWORD
);
$service = new Xi\Sms\SmsService($gw);
$msg = new Xi\Sms\SmsMessage(
$sms->message(),
self::parsePhoneNumber($sms->from()),
self::parsePhoneNumber($sms->to())
);
$response = $service->send($msg);
return !empty($response);
}
/**
* Parses a phone number to fit Clickatell