Piwik\Plugins\MobileMessaging\

SMSProvider

The SMSProvider abstract class is used as a base class for SMS provider implementations.

To create your own custom SMSProvider extend this class and implement the methods to send text messages. The class needs to be placed in a SMSProvider directory of your plugin.

Methods

The abstract class defines the following methods:

getId()

Get the ID of the SMS Provider.

Eg 'Clockwork' or 'FreeMobile'

Signature

  • It returns a string value.

getDescription()

Get a description about the SMS Provider.

For example who the SMS Provider is, instructions how the API Key needs to be set, and more. You may return HTML here for better formatting.

Signature

  • It returns a string value.

verifyCredential()

Verify the SMS API credential.

Signature

  • It accepts the following parameter(s):

    • $credentials (array) — contains credentials (eg. like API key, user name, ...)
  • Returns: bool — true if credentials are valid, false otherwise

getCreditLeft()

Get the amount of remaining credits.

Signature

  • It accepts the following parameter(s):

    • $credentials (array) — contains credentials (eg. like API key, user name, ...)
  • Returns: string — remaining credits

sendSMS()

Actually send the given text message.

This method should only send the text message, it should not trigger any notifications etc.

Signature

  • It accepts the following parameter(s):

    • $credentials (array) — contains credentials (eg. like API key, user name, ...)
    • $smsText (string) —

    • $phoneNumber (string) —

    • $from (string) —

  • Returns: bool — true

getCredentialFields()

Defines the fields that needs to be filled up to provide credentials

Example: array ( array( 'type' => 'text', 'name' => 'apiKey', 'title' => 'Translation_Key_To_Use' ) )

Signature

  • It returns a array value.

isAvailable()

Defines whether the SMS Provider is available.

If a certain provider should be used only be a limited range of users you can restrict the provider here. For example there is a Development SMS Provider that is only available when the development is actually enabled. You could also create a SMS Provider that is only available to Super Users etc. Usually this method does not have to be implemented by a SMS Provider.

Signature

  • It returns a bool value.