SMSProvider
Click here if you want to read this article for the latest version.
Piwik\Plugins\MobileMessaging\
SMSProvider
The SMSProvider abstract class is used as a base class for SMS provider implementations.
Methods
The abstract class defines the following methods:
getId()— Get the ID of the SMS Provider.getDescription()— Get a description about the SMS Provider.verifyCredential()— Verify the SMS API credential.getCreditLeft()— Get the amount of remaining credits.sendSMS()— Actually send the given text message.getCredentialFields()— Defines the fields that needs to be filled up to provide credentialsisAvailable()— Defines whether the SMS Provider is available.
getId()
Get the ID of the SMS Provider. Eg 'Clockwork' or 'FreeMobile'
Signature
- It returns a
stringvalue.
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
stringvalue.
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
arrayvalue.
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
boolvalue.