Use Clickatell’s PHP library with our HTTP or REST messaging APIs to interact with the Clickatell SMS Gateway.
When to use this
Used by web-based clients to send SMS alerts and notifications. After signing up, use this PHP library to include in your project.
This library uses composer and can be acquired using the following in your composer.json file.
The library currently supports the
Sending to multiple numbers
to parameter can take an array of numbers. If you specify only a single number e.g.:
the library will automatically convert it to an array for your convenience.
Supported API calls
The available calls are defined in the
The library comes with a
ClickatellEvent class that is a wrapper for any of the other transports. This class can assist you with debugging or logging API interactions.
This class uses the Proxy Pattern.
Dealing with extra parameters in sendMessage
For usability purposes the
sendMessage call focuses on the recipients and the content. In order to specify any of the additional parameters defined in the Clickatell document, you can use the
extra parameter and pass them as an array.
You can listen to Clickatell callbacks by using the
Callback::parseCallback(); function. It’s a helper function to make sure the required parameters are included in the
Parameters: apiMsgId, cliMsgId, to, timestamp, from, status, charge
The library has built-in support for sending OTPs (One Time Pins) to verify the identity of a user. This is helpful as a second step during authentication or to validate that the person you are interacting with is a real entity.
In order to start using the bundle, you first need to register it within your
You also need to specify your Clickatell credentials in your application config. In this example, YAML is used.
The ‘class’ parameter
The class parameter can be any class that inherits from
Clickatell\Clickatell. The default value for this is
The ‘arguments’ parameter
This parameter will be the constructor arguments for your class. What you specify here will depend on what your class takes as constructor arguments.
Clickatell\Api\ClickatellRestclass takes one argument – your API token (issued by Clickatell)
Clickatell\Api\ClickatellHttpclass takes three arguments – your username, password and API ID (issued by Clickatell)
The bundle usage
Once you have configured the component, you can utilize it in your controllers as shown below:
You can see our other libraries and more documentation at the Clickatell APIs and Libraries Project.
Submit a Comment
Ask the Community
Visit Stack Overflow to join our community of developers and find the answer you need
Contact our support team and one of our agents will be in touch with you to answer any questions you have