Download the PHP package coreproc/chikka-api-sdk without Composer
On this page you can find all versions of the php package coreproc/chikka-api-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package chikka-api-sdk
Chikka API SDK for PHP
A PHP library for interacting with the Chikka API for sending and receiving SMS.
Note: This is not an official Chikka library
Install
Run the following command at the root of your project (assuming you have Composer and a composer.json file already)
Usage
Sending SMS
Basic sending of an SMS can be summarized in four steps:
- Instantiate a
ChikkaClient
object with your credentials and shortcode. - Instantiate an
Sms
object with your desired message. - Instantiate an
SmsTransporter
using theChikkaClient
andSms
objects you just created. - Send using the
SmsTransporter
Here is an example:
Determining the response of an SMS
The send()
method of the SmsTransporter
class returns an object containing the response from Chikka's server. A sample successful response is below:
A sample error response would be as follows:
However, determining the response of the SMS API from this standpoint would result in an archaic code base of and this would best be handled by a separate class.
You can implement an SmsTransporterActionsContract
to a class to handle the responses. A sample class that implements SmsTransporterActionsContract
is as follows:
The SmsTransporterActionsContract
interface has four notable methods:
-
onStart()
method is called at the start of sending an SMS -
onInvalid()
method is called when the SMS being sent is invalid. This usually means that one of your parameters are incorrect and resulted in a 400 response code from Chikka's server. Handle your SMS as necessary in this method. TheException
object passed here contains the code and the message of the response and you can get them by using$exception->getCode()
and$exception->getMessage()
, respectively. -
onError()
method is called when a server exception is encountered. This usually means that the Chikka server responded with a 500 level response and your SMS was not successfully transmitted anywhere. You should probably try sending your SMS again if this occurs. onSuccess()
method is called when an SMS was successfully accepted by Chikka's servers.
To use this SampleSmsTransporterActions
class when sending an SMS, simply include it as the first parameter of the send()
method. Here is an example:
Note: When using the send()
method without a SmsTransporterActionsContract class, the default class that is used is Coreproc\Chikka\Transporters\SmsTransporterActions
.
You can use that class as a reference for creating your own SmsTransporterActionsContract class.
All versions of chikka-api-sdk with dependencies
vlucas/valitron Version ~1.2
nesbot/carbon Version ~1.14
coreproc/msisdn-ph Version 1.1.*
psr/log Version ~1.0.0