A simple Object Oriented PHP Client for Termii SMS API

Overview

Termii Client

A simple Object Oriented PHP Client for Termii SMS API.

Uses Termii API.

Requirements

  • PHP >= 7.2
  • Guzzlehttp ~6|~7

Installation

Via Composer.

PHP 7.2+:

composer require mane-olawale/termii

You now have Termii Client installed in vendor/mane-olawale/termii

And an handy autoload file to include in your project in vendor/autoload.php

Basic usage of Termii client

10, "time_to_live" => 30, "length" => 6, "placeholder" => '{token}', 'pin_type' => 'ALPHANUMERIC', 'message_type' => 'ALPHANUMERIC', 'type' => 'plain', ]); $client->sms->send('2347041945964', 'Hello World!'); // You can change any option later $client->fillOptions([ "attempts" => 5, "time_to_live" => 20, "length" => 4, "placeholder" => '{pin}', ]); ">


// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use ManeOlawale\Termii\Client;

// Create a new Client instance
$client = new Client('{api_key}');

// Create a new Client instance and set options
$client = new Client('{api_key}', [
            'sender_id' => 'Olawale',
            'channel' => 'generic',
            "attempts" => 10,
            "time_to_live" => 30,
            "length" => 6,
            "placeholder" => '{token}',
            'pin_type' => 'ALPHANUMERIC',
            'message_type' => 'ALPHANUMERIC',
            'type' => 'plain',
        ]);

$client->sms->send('2347041945964', 'Hello World!');

// You can change any option later

$client->fillOptions([
            "attempts" => 5,
            "time_to_live" => 20,
            "length" => 4,
            "placeholder" => '{pin}',
        ]);

Sender

Getting Sender ID list

Uses Sender ID.



// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use ManeOlawale\Termii\Client;

$client = new Client('{api_key}');

$client->sender->list();

Note: We didn`t add the Sender id and channel becuase they are optional and they can always be passed later on the client object or the SMS API handler.

Request Sender ID

Uses Request Sender ID.



// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';

use ManeOlawale\Termii\Client;

$client = new Client('{api_key}');

$client->sender->request('Olawale', 'Friendship based Notifications', 'Mane Olawale');

SMS

Send Message

Uses Switch - Messaging.



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}', [
            'sender_id' => '{sender_id}',
            'channel' => '{channel}',
        ]);

    return $client->sms->send('2347041945964', 'Testing');

Custom Sender ID or Channel



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}', [
            'sender_id' => '{sender_id}',
            'channel' => '{channel}',
        ]);

    return $client->sms->send('2347041945964', 'Hello World', 'Olawale', 'generic');

    // OR probably omit sender id or channel

    return $client->sms->send('2347041945964', 'Hello World', null, 'generic');

Send Number

Uses Switch - Number.



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->sms->number('2347041945964', 'Hello World');

Template

Uses Switch - Template.



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->sms->template('2347041945964', '{template_id}', [
            'product_name' => 'Termii',
            'otp' => '120435',
            'expiry_time' => '10 minutes'
    ], '{device_id}');

Token

Send Token

Uses Send Token.

10, "time_to_live" => 30, "length" => 6, "placeholder" => '{token}', 'type' => 'NUMERIC', ]); ">


    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}', [
            'sender_id' => '{sender_id}',
            'channel' => '{channel}',
        ]);

    // You can choose to omit the pin options if you have set them when creating the client instance
    return $client->token->sendToken('2347041945964', '{token} is your friendship verification token', [
        "attempts" => 10,
        "time_to_live" => 30,
        "length" => 6,
        "placeholder" => '{token}',
        'type' => 'NUMERIC',
    ]);

Custom Sender ID or Channel

10, "time_to_live" => 30, "length" => 6, "placeholder" => '{token}', 'type' => 'NUMERIC', ], 'Olawale', 'generic'); // OR probably omit sender id or channel return $client->token->sendToken('2347041945964', '{token} is your friendship verification token', [ "attempts" => 10, "time_to_live" => 30, "length" => 6, "placeholder" => '{token}', 'type' => 'NUMERIC', ], null, 'generic'); ">


    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}', [
            'sender_id' => '{sender_id}',
            'channel' => '{channel}',
        ]);

    return $client->token->sendToken('2347041945964', '{token} is your friendship verification token', [
        "attempts" => 10,
        "time_to_live" => 30,
        "length" => 6,
        "placeholder" => '{token}',
        'type' => 'NUMERIC',
    ], 'Olawale', 'generic');

    // OR probably omit sender id or channel

    return $client->token->sendToken('2347041945964', '{token} is your friendship verification token', [
        "attempts" => 10,
        "time_to_live" => 30,
        "length" => 6,
        "placeholder" => '{token}',
        'type' => 'NUMERIC',
    ], null, 'generic');

Verify Token

Uses Verify Token.



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->token->verify('a2d671d7-e4fd-41d5-9b13-30c192309306', '123456');

For men and women of few words



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    // Returns True if token is verified else returns false
    return $client->token->verified('a2d671d7-e4fd-41d5-9b13-30c192309306', '123456');

    // Returns True if token fails to verify else returns false
    return $client->token->failed('a2d671d7-e4fd-41d5-9b13-30c192309306', '123456');

    // Returns True if token exists but has expired else returns false
    return $client->token->expired('a2d671d7-e4fd-41d5-9b13-30c192309306', '123456');

Send In App Token

Uses Send In App Token.

10, "time_to_live" => 30, "length" => 6, ]); ">


    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->token->sendInAppToken('2347041945964', [
        "attempts" => 10,
        "time_to_live" => 30,
        "length" => 6,
    ]);

Account insights

Balance

Uses Balance.



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->insights->balance();

Inbox

Uses Inbox.



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->insights->inbox();

    /**
     * Get only the data of a specific message by passing its message_id
    */
    return $client->insights->inbox('43224343447041945964');

Search

Uses Search.



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->insights->search('2347041945964');

The search Api is used majorly for checking if a number is DND active, so there are two helper functions to ease the check



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->insights->isDnd('2347041945964');

    // OR

    return $client->insights->isNotDnd('2347041945964');

Status

Uses Status.



    // This file is generated by Composer
    require_once __DIR__ . '/vendor/autoload.php';

    use ManeOlawale\Termii\Client;

    $client = new Client('{api_key}');

    return $client->insights->number('2347041945964');
You might also like...
API client for ThePay - payment gate API
API client for ThePay - payment gate API

This is the official highly compatible public package of The Pay SDK which interacts with The Pay's REST API. To get started see examples below.

Code Quiz MonoRepo (API, API Client, App)

Code Quiz Welcome to the Code Quiz Open Source project from How To Code Well. This is an Open Source project that includes an API and an App for the d

⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC. This project is a work-in-progress. Code and docume

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

php 8 client for the lemon.markets api

lemon.markets php client This repository contains a php 8+ compatible client for the https://lemon.markets API. The documentation of the API can be fo

PHP client for Microsoft Azure Face API.

Microsoft Azure Face API PHP client A PHP library that utilizes Azure Face REST API. Requirements PHP = 7.4 Installation composer require darmen/php-

Google PHP API Client Services

Google PHP API Client Services

PHP Client for the GoFlink API

GoFlink PHP API Client This project is an unofficial library to communicate with the GoFlink API from your PHP project. Documentation about the API is

A PHP client for the official Kizeo Forms API V3+. 📌

Kizeo Forms API V3+ - PHP This is a Swagger generated doc for Kizeo REST API 3. You can find additionnal documentation here : Online documentation. Th

Comments
  • fix: persists base url after changing it

    fix: persists base url after changing it

    No one have create issues for this yet but this is a bug... i found out that the base url on guzzle wont be updated after you change the url using the Client::fillOptions() method.

    Since termii now have multiple base urls, this can be a very serious issue.

    opened by Mane-Olawale 0
  • [ADDITION: Docs, Client]

    [ADDITION: Docs, Client]

    • Added dynamic property to Client for getting the Api handler
    • Added doc block to files, methods and properties
    • Documented the new changes to the README.md
    opened by Mane-Olawale 0
Releases(v1.2.3)
  • v1.2.3(Aug 1, 2022)

    What's Changed

    • Add header to docs by @Mane-Olawale in https://github.com/Mane-Olawale/termii/pull/17
    • Enhanced response for API handlers by @Mane-Olawale in https://github.com/Mane-Olawale/termii/pull/18

    Full Changelog: https://github.com/Mane-Olawale/termii/compare/v1.2.1...v1.2.3

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Feb 12, 2022)

    What's Changed

    • Update issue templates by @Mane-Olawale in https://github.com/Mane-Olawale/termii/pull/15
    • Create CONTRIBUTING.md by @Mane-Olawale in https://github.com/Mane-Olawale/termii/pull/16

    Full Changelog: https://github.com/Mane-Olawale/termii/compare/v1.2...v1.2.1

    Source code(tar.gz)
    Source code(zip)
  • v1.2(Feb 10, 2022)

    What's Changed

    • Http manager by @Mane-Olawale in https://github.com/Mane-Olawale/termii/pull/9
    • Default base url corrected by @drchibs in https://github.com/Mane-Olawale/termii/pull/10
    • New setHttpManager method by @Mane-Olawale in https://github.com/Mane-Olawale/termii/pull/12
    • fix: persists base url after changing it by @Mane-Olawale in https://github.com/Mane-Olawale/termii/pull/13
    • chore: update docs by @Mane-Olawale in https://github.com/Mane-Olawale/termii/pull/14

    New Contributors

    • @drchibs made their first contribution in https://github.com/Mane-Olawale/termii/pull/10

    Full Changelog: https://github.com/Mane-Olawale/termii/compare/v1.1...v1.2

    Source code(tar.gz)
    Source code(zip)
  • v1.1(Jul 1, 2021)

    This version involves refactoring and code style.

    Changes

    #7 [CHORE: composer.json] updated php requirement #8 conform to psr-12 standards ~ Olawale

    Source code(tar.gz)
    Source code(zip)
  • v1.0(May 23, 2021)

    This is the frist Release of the library. Compatible with:

    • PHP 7.3
    • PHP 7.4
    • PHP 8.0

    Changes

    #3 Added tests and Fixes

    • Optimized Client objects
    • Corrected misplaced Api parameter
    • And it is Ready for production.

    ~ Olawale

    Source code(tar.gz)
    Source code(zip)
  • v0.1(May 21, 2021)

    The Embryo

    This is a pre-release and it`s not ready for production. We are still currently working towards making it safe and better to use. We will advice you to use this release only for development.

    ~ Olawale

    Source code(tar.gz)
    Source code(zip)
Owner
Ilesanmi Olawale Adedotun
An Engineer++ and a PHP developer, love backends, I am from Ekiti state, Nigeria. National Deploma in Civil engineering.
Ilesanmi Olawale Adedotun
Пакет позволяющий работать с REST API SMS-сервиса «SMS Aero»

SMS-сервис «SMS Aero» ?? Пакет позволяющий работать с REST API SMS-сервиса «SMS Aero» ?? Изменения: Все заметные изменения в этом проекте будут задоку

Артём Соколовский 2 Feb 6, 2022
OpenAI API Client is a component-oriented, extensible client library for the OpenAI API. It's designed to be faster and more memory efficient than traditional PHP libraries.

OpenAI API Client in PHP (community-maintained) This library is a component-oriented, extensible client library for the OpenAI API. It's designed to b

Mounir R'Quiba 6 Jun 14, 2023
playSMS is a web interface for SMS gateways and bulk SMS services

README Latest development release is playSMS version 1.4.4-beta4 Latest stable release is playSMS version 1.4.3 Official project website: https://play

playSMS 662 Dec 31, 2022
Nexmo REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.

Client Library for PHP Support Notice This library and it's associated packages, nexmo/client and nexmo/client-core have transitioned into a "Maintena

Nexmo 75 Sep 23, 2022
NovaGram - An elegant, Object-Oriented, reliable PHP Telegram Bot Library

An elegant, Object-Oriented, reliable PHP Telegram Bot Library Full Documentation • Public support group Examples • Features • Installation ?

Gaetano 165 Jan 6, 2023
oursms.app client library that allows you to send SMS

Oursms laravel client https://oursms.app client library that allows you to send SMS Installation Install oursms client with composer composer requir

Khalid Mohammad 11 Aug 27, 2022
Google-api-php-client - A PHP client library for accessing Google APIs

Google APIs Client Library for PHP Reference Docs https://googleapis.github.io/google-api-php-client/main/ License Apache 2.0 The Google API Client Li

Google APIs 8.4k Dec 30, 2022
یک پکیج لاراول برای ارسال ، دریافت و... پیامک (SMS)

پکیج لاراول SMS با استفاده از این پکیج می توانید به پنل خود در وب سایت sms.ir متصل شوید و یک سیستم ارسال و دریافت SMS ایرانی در لاراول داشته باشید. به

Ali Zeinodin 15 Nov 30, 2022
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

Sergey Bykov 63 Feb 14, 2022
DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

Kévin Dunglas 25 Jul 27, 2022