2017 © Pedro Peláez
 

cakephp-plugin cakephp-sms

SMS Plugin for CakePHP

image

fotografde/cakephp-sms

SMS Plugin for CakePHP

  • Thursday, May 24, 2018
  • by felixmaier1989
  • Repository
  • 5 Watchers
  • 11 Stars
  • 35,282 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 9 % Grown

The README.md

CakePHP Sms Plugin

Build Status Minimum PHP Version License Total Downloads, (*1)

Send SMS with CakePHP., (*2)

Usage

``` php App::uses('CakeSms', 'Sms.Network/Sms');, (*3)

$CakeSms = new CakeSms('default'); $CakeSms->to('+491234567890'); $CakeSms->from('+841234567890'); $CakeSms->send('Hello world!');, (*4)


## Installation via Composer ``` javascript "require": { "fotografde/cakephp-sms": ">=1.0.0" }

Configuration

Load plugin in Config/bootstrap.php, (*5)

``` php CakePlugin::load('Sms');, (*6)


Create Config/sms.php ``` php class SmsConfig { public $default = array( 'transport' => 'Clickatell', // will use class ClickatellSmsTransport ); }

Implement a transport class under Lib/Network/Sms/. We recommend implementing Xi SMS, this way for example:, (*7)

``` php /** * Send SMS through SMS provider Clickatell */, (*8)

use Xi\Sms\Gateway\ClickatellGateway;, (*9)

App::uses('AbstractSmsTransport', 'Sms.Network/Sms');, (*10)

class ClickatellSmsTransport extends AbstractSmsTransport {, (*11)

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 requirements
 * from +49123[...] to 49123[...]
 *
 * @param array|string $phoneNumber
 * @return array|string|bool
 */
public static function parsePhoneNumber($phoneNumber) {
    if (is_array($phoneNumber)) {
        return array_map('self::parsePhoneNumber', $phoneNumber);
    }
    if (preg_match('/^\+([0-9]+)$/', (string) $phoneNumber, $matches)) {
        return $matches[1];
    }
    return false;
}

} ```, (*12)

The Versions

24/05 2018

dev-master

9999999-dev http://github.com/fotografde/cakephp-sms

SMS Plugin for CakePHP

  Sources   Download

MIT

The Requires

 

php cakephp sms message mobile short cake

28/08 2017

1.0.2

1.0.2.0 http://github.com/fotografde/cakephp-sms

SMS Plugin for CakePHP

  Sources   Download

MIT

The Requires

 

php cakephp sms message mobile short cake

24/08 2017

1.0.1

1.0.1.0 http://github.com/fotografde/cakephp-sms

SMS Plugin for CakePHP

  Sources   Download

MIT

The Requires

 

php cakephp sms message mobile short cake

11/05 2015

1.0.0

1.0.0.0 http://github.com/fotografde/cakephp-sms

SMS Plugin for CakePHP

  Sources   Download

MIT

The Requires

 

php cakephp sms message mobile short cake