Git Product home page Git Product logo

smsmanager's Introduction

PHP Client for SmsManager.cz

Build Status Quality Score Downloads Code Coverage GitHub Issues

Library for PHP that can send SMS messages via SmsManager.cz gateway. (not all API methods are implemented for now)

Installation

composer require simpod/sms-manager

Usage

Use SmsManager interface in your code, eg.:

public function __construct(SmsManager $smsManager) {
    ...
}

and alias SMSManager to ApiSmsManager for your production usage.

Example with Symfony:

services:
    SimPod\SmsManager\SmsManager:
        alias: SimPod\SmsManager\ApiSmsManager

To send message, create new SmsMessage:

$smsMessage = new SmsMessage(
    'message text',
    [
        '+420777888999'
    ],
    RequestType::getRequestTypeLow() // optional, defaults to High
    'sender' // optional
    1 // optional, CustomID
);

$smsManager->send($smsMessage);

Third parameter of SmsMessage is RequestType that is represented by RequestType class. Eg. low request type is instantiated with RequestType::getRequestTypeLow().

smsmanager's People

Contributors

dependabot-preview[bot] avatar janbukva avatar simpod avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

smsmanager's Issues

Sanity checking phone number via Beberlei\Assertion::e164() worth it?

The ApiSmsManager checks whether recipients' phone numbers follow the E.164 recommendation (lines 98 - 102):

foreach ($smsMessage->getRecipients() as $recipient) {
    Assertion::e164($recipient);
    $numberList->addChild('Number', $recipient);
    $hasAnyNumber = true;
}

It does this by pulling the whole Beberlei/Assert library and calling the method \Assert\Assertion::e164(), which by itself is nothing more than a small regex:

if (!\preg_match('/^\+?[1-9]\d{1,14}$/', $value))

My questions:

  1. Is it worth it pulling down a whole library just for one regex? Maybe it would be better to drop the dependency and just check this manually, with your own method.
  2. The E.164 is just a recommendation and it doesn't get followed. See Falsehood about phone numbers nr. 15:

ITU-T specifies that a phone number cannot be longer than fifteen digits, with one to three digits reserved for the country calling code, but valid numbers in Germany have been assigned that are longer than this.

Maybe this library could drop the Assertion dependency and just loosely sanity-check whether the given number looks like a phone number, something like

if ( ! preg_match('/^\+?\d+$/', $phoneNumber))

Checking if the number is a real phone number (let alone one which can receive SMS) is much more complicated and there is a whole huge library for it, so I would leave it out.

What do you think?

Authorize API requests with Apikey

With help of the https://smsmanager.cz/api/xml documentation I was able to successfully send SMS with the new Apikey field.
Otherwise I'm getting Unauthorized exception. Was trying to use Email&Password and Email&Token combination.

$requestHeader = $xml->addChild('RequestHeader');
$requestHeader->addChild('Username', $this->username);
$requestHeader->addChild('Password', $this->password);

        $requestHeader->addChild('Apikey', $this->password);

I'm testing this with a brand new SMSManager account, the old library LS/SMSManager is still working for LS.

In SendingFailed.php line 18:
                                                                                                  
  Sending failed for "+420xxxxxxxxx" because "The username or password you entered is incorrect"  

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.