Download the PHP package ilebora/borasms without Composer
On this page you can find all versions of the php package ilebora/borasms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ilebora/borasms
More information about ilebora/borasms
Files in ilebora/borasms
Package borasms
Short Description A package for sending SMS via the BoraSMS API.
License MIT
Informations about the package borasms
BoraSMS
BoraSMS
is a PHP library for sending SMS messages using a custom API. This library allows you to easily send SMS messages, configure success and failure handlers, and customize your API credentials.
Installation
To install the package, you can use Composer:
Configuration
Before using BoraSMS
, you'll need to provide your API credentials (API key, user ID, and display name). There are two ways to do this:
-
Using Environment Variables (
.env
file)
The package can automatically read the API credentials from your.env
file using vlucas/phpdotenv. - Using Getter and Setter Methods
Alternatively, you can set the credentials directly via getter and setter methods.
Example .env
file
Create a .env
file in the root of your project with the following contents:
Example Usage
Below is an example of how to use the BoraSMS
class.
Methods Overview
-
__construct()
Optionally loads credentials from environment variables. Throws an exception if required credentials are missing. -
setApiVersin($apiVersion)
Sets the API version to use. -
setApiKey($apiKey)
Sets the API key used for authentication. -
setUserID($userID)
Sets the user ID used for authentication. -
setDisplayName($displayName)
Sets the display name used for sending SMS. -
setPhone($phone)
Sets the recipient phone number. -
setMessage($message)
Sets the message to be sent. -
setOnSuccess($onSuccess)
Sets the URL to be called on success. -
setOnFailure($onFailure)
Sets the URL to be called on failure. sendSMS()
Sends the SMS and returns the response from the API.
Handling Responses
The sendSMS()
method returns the JSON API response. You can use this response to check the status of the SMS request or handle it accordingly (e.g., display a success message or log an error).
Example Callback Response
The response returned by the API might look like this:
You can process this response as needed to update your application's UI or log the result.
License
This package is open-source and licensed under the MIT License. Feel free to modify and contribute to the project.
Notes:
-
Error Handling:
If the required credentials are missing, the constructor will throw an exception. It's important to handle this gracefully in your application. - Security Considerations:
It's recommended to store sensitive information like the API key and user ID in environment variables (via.env
file) instead of hardcoding them into your source code.