swiftsmsgh/swiftsmsgh-api-sdk

PHP SDK for the Swiftsms-GH Bulk SMS API

v1.0.0 2024-01-19 13:30 UTC

This package is auto-updated.

Last update: 2024-05-19 15:11:22 UTC


README

The Swiftsms-GH PHP SDK provides a suitable approach to the Swiftsms-GH API from applications written in PHP. It includes pre-defined set of classes and functions for API resource that initialize themselves from API responses.

The library provides other features. For Example:

  1. Easy configuration path for fast setup and use
  2. Helpers for pagination.

You can sign up for an Swiftsms-GH account at swiftsmsgh.com

Prerequisites

PHP ^8.0 and later

Installation

Via Composer

$ composer require swiftsmsgh/swiftsmsgh-api-sdk

Via Git Bash

git clone https://github.com/majesty-scofield/swiftsmsgh-api-sdk.git

Documentation

Please see https://swiftsmsgh.com/developer for up-to-date documentation

Usage

Step 1:

If you install the Swiftsms-GH PHP SDK via Git Clone then load the Swiftsms-GH PHP API class file and use namespace.

require_once '/path/to/src/Swiftsmsgh.php';
use Swiftsms\Swiftsmsgh;

If you install Swiftsms-GH PHP SDK via Composer require the autoload.php file in the index.php of your project or whatever file you need to use Swiftsms-GH PHP API classes.

require __DIR__ . '/vendor/autoload.php';
use Swiftsms\Swiftsmsgh;

The Swiftsms-GH PHP SDK endpoints are RESTful, and consume and return JSON. All Http endpoints requires an API Key in the request header.

For more information on how to get an API Key visit here to copy or generate new key for authorization.

HTTP ENDPOINTS

Step 2:

Instantiate the SwiftsmsghSMSSDKAPI

$api_token = "Enter Your API Token here";

$sender_id = "Enter your approved Sender ID here";

$client = new Swiftsmsgh\SwiftsmsghSMS($api_token, $sender_id);

Send SMS

$recipients = "233500000000,233540000000";

$message = "This is a test message";

$response = $client->send_sms($recipients, $message);

Check SMS Credit Balance

$url = "https://app.swiftsmsgh.com/api/v3/balance";

$get_credit_balance = $client->check_balance($url);

View Profile

$url = "https://app.swiftsmsgh.com/api/v3/me";

$get_profile = $client->profile($url);

Status Code

Status Message
ok Successfully Send
100 Bad gateway requested
101 Wrong action
102 Authentication failed
103 Invalid phone number
104 Phone coverage not active
105 Insufficient balance
106 Invalid Sender ID
107 Invalid SMS Type
108 SMS Gateway not active
109 Invalid Schedule Time
110 Media url required
111 SMS contain spam word. Wait for approval