kemboielvis/smsgenius-php-sdk

v1.1.0 2024-02-12 13:05 UTC

This package is auto-updated.

Last update: 2025-07-12 16:10:43 UTC


README

This SDK helps one to integrate their applications with SMSGenius API for sending messages with ease

The official documentation is on sms.genius.ke

You can install the php sdk using composer

 composer require kemboielvis/smsgenius-php-sdk

SMS Genius platform can do the following:
1. Sending SMS to any network
2. Sending WhatsApp messages

HOW TO USE THE SDK

  1. USING SMS PLATFORM

    First initialize the main class and pass in API key as the parameter

    You can get you api key from sms.genius.ke go to Tools and add a new key. You can add its permissions

<?php

require "./vendor/autoload.php";

$smsGenius = new \Kemboielvis22\SmsgeniusPhpSdk\SMSGenius("APIKEY");
  • Delete Received Messages [params(id)]
  • $sms = $smsGenius->SMSClass();
    // delete Received message with the ID passed in as a parameter
    $response = $sms->deleteReceivedMessages("id");
    // Response is an array 
  • Delete SMS Campaign [params(id)]
  • $sms = $smsGenius->SMSClass();
    // Delete an SMS Campaign with a specific campaign ID
    $response = $sms->deleteSMSCampaign("id");
    //The response is an array 
  • Delete Sent Messages [params(id)]
  • $sms = $smsGenius->SMSClass();
    // Delete a sent message with specific message id
    $response = $sms->deleteSentMessage("id")
    // Response is an array
  • Get Devices
  • $sms = $smsGenius->SMSClass();
    //Get all devices connected with you account
    $devices = $sms->getDevices();
    // Devices is an array containing all devices connected with your account
  • Get Pending messages
  • $sms = $smsGenius->SMSClass();
    // Get all pending messages
    $pendingMessages = $sms->getPendingMessages();
    // Pending Messages is an array 
  • Get Received Messages
  • $sms = $smsGenius->SMSClass();
    // Get all Received Messages
    $receivedMessages = $sms->getReceivedMessages();
    // Received Messages is an array 
  • Get SMS Campaigns
  • $sms = $smsGenius->SMSClass();
    // Get all SMS Campaigns available
    $smsCampaign = $sms->getSMSCampaigns();
    // SMS Campaign is an array 
  • Get Sent Messages
  • $sms = $smsGenius->SMSClass();
    // Get all sent Messages
    $sentMessages = $sms->getSentMessages();
    // Sent messages is an array 
  • Send Bulk Messages
  • // For devices mode 
      $array = [      
          "mode" => "devices", // There are credits or devices
          "campaign" => "bulk test",
          "numbers" => "+254712123456,+639123456789,+639123456789",
          "groups" => "1,2,3,4", // ( OPTIONAL )
          "device" => "00000000-0000-0000-d57d-f30cb6a89289", // For type Devices
          "sim" => 1, // For type Devices
          "priority" => 1, // ( OPTIONAL ) For type Devices 
          "message" => "Hello World!"
      ];
    // For credits mode
        $array = [      
          "mode" => "credits", // There are credits or devices
          "campaign" => "bulk test",      
          "groups" => "1,2,3,4",      
          "message" => "Hello World!"
      ];
      $sms = $smsGenius->SMSClass();
       // Send Single message
       $response = $sms->sendBulkSMS($array);
       // response is an array
  • Send Single Messages
  • // For mode device
    $array = [ // your API secret from (Tools -> API Keys) page
          "mode" => "devices",
          "device" => "00000000-0000-0000-d57d-f30cb6a89289",
          "sim" => 1, // Sim slot number Only for devices
          "priority" => 1, // ( OPTIONAL ) If you want to send the messages as priority, 1 for yes and 2 for no. For "devices" mode only.
          "phone" => "+254712123456",
          "message" => "Hello World!"
    ];
    // For Credits mode
    $array = [ // your API secret from (Tools -> API Keys) page
          "mode" => "credits",      
          "phone" => "+254712123456",
          "message" => "Hello World!",
          "gateway" => 3, // gateway number You can get it from getGatewayRoutes()
    ];
    
    $sms = $smsGenius->SMSClass();
    // Send Single message
    $response = $sms->sendSingleSMS($array);
    // response is an array
  • Start SMS Campaign [ params(Campaign ID)]
  • $sms = $smsGenius->SMSClass();
    // Start SMS Campaign
    // Pass in the campaign ID To start the campaign
    $campaign = $sms->startSMSCampaign("Campaign ID")
    // Campaign is an array 
  • Stop SMS Campaign [params(campaign ID)]
  • $sms = $smsGenius->SMSClass();
    // Stop a SMS campaign.
    // Pass the campaign ID as the parameter 
    $campaign = $sms->stopSMSCampaign("Campaign ID");
    // campaign is an array 
    1. ACCOUNT
  • Get Partner Earnings
  • $account = $smsGenius->account();
    // Get partner earnings
    $earnings = $account->getPartnerEarnings();
    // Earnings is an array 
  • Get remaining Credits
  • $account = $smsGenius->account();
    // Get remaining credits
    $credits = $account->getRemainingCredits();
    // Credits is an array
  • Get Subscription Packages
  • $account = $smsGenius->account();
    // Get subscription packages
    $packages = $account->getSubscriptionPackage();
    // Subscription packages is an array 
    1. System
  • Get Gateway routes
  • $system = $smsGenius->System();
    // Get all gateway routes
    $routes = $system->getGatewayRoutes();
    // Routes is an array 
  • Get Shortener's
  • $system = $smsGenius->System();
    // Get all system shorteners
    $shorteners = $system->getShorteners();
    // Shortners is an Array

    4 USSD

  • Clear Pending USSD
  • $ussd = $smsGenius->USSD();
    // Clear pending USSD's 
    $response = $ussd->clearPendingUSSD();
    // Response is an array
  • Delete USSD Request [ params(ussdid) ]
  • $ussd = $smsGenius->USSD();
    // Delete a USSD request
    $response = $ussd->deleteUSSDRequest("USSDID");
    // Response is an array
  • Get USSD Requests
  • $ussd = $smsGenius->USSD();
    // Get all USSD request
    $allUssd = $ussd->getUSSDRequest();
    // all USSD is an array
  • Send a USSD Request
  • $array = [
    
    ];
    $ussd = $smsGenius->USSD();
    // Send a USSD request
    $response = $ussd->sendUSSDRequest();
    // Response is an array
    1. OTP
  • Send OTP
  • $array = [
    
    ];
    $otp = $smsGenius->OTPClass();
    // Send an otp to a specific phone number
    $response = $otp->sendOTP();
    // Response is an array 
  • Verify OTP [ params(OTP code) ]
  • $otp = $smsGenius->OTPClass();
    // Verify a sent OTP
    $response = $otp->verifyOTP("OTP");
    // Response is an array
    1. WhatsApp Messaging
  • Delete Received Chat
  • $whatsapp = $smsGenius->WhatsApp();
    // Delete a specific Chat ID
    $response = $whatsapp->deleteReceivedChat("chatID");
    // Get the response (array)
  • Delete Sent Chat
  • $whatsapp = $smsGenius->WhatsApp();
    // Delete a sent chat with a specific ID
    $response = $whatsapp->deleteSentChat("chatID");
    // Get the response (array)
  • Delete WhatsApp Campaign
  • $whatsapp = $smsGenius->WhatsApp();
    // Delete whatsapp campaign
    $response = $whatsapp->deleteWhatsAppCampaign("chatid");
    // Get the response (array)
  • Get Accounts
  • $whatsapp = $smsGenius->WhatsApp();
    // Get accounts
    $accounts = $whatsapp->getAccounts();
    // Get response 
  • Get Pending WhatsApp Chats
  • $whatsapp = $smsGenius->WhatsApp();
    // Get pending chats
    $pending = $whatsapp->getPendingChats();
    // Get response (Array)
  • Get Received Chats
  • $whatsapp = $smsGenius->WhatsApp();
    // Get received chats
    $received = $whatsapp->getReceivedChats();
    // Get response  (array)
  • Get Sent Chats
  • $whatsapp = $smsGenius->WhatsApp();
    // Get sent messages
    $sent = $whatsapp->getSentChats();
    // response ( Array )
  • Get WhatsApp Campaign Chats
  • $whatsapp = $smsGenius->WhatsApp();
    // Get WhatsApp Campaign Chats
    $campaign = $whatsapp->getWhatsAppCampaign();
    // Response (Array)
  • Post Bulk Messages
  • $array = [
          "account" => 1, // account ID
          "campaign" => "bulk test",
          "numbers" => "+254712123456,+639123456789,+639123456789",
          "groups" => "1,2,3,4", // ( OPTIONAL )
          "message" => "Hello World!",
          "type" => "text" // "text", "media", "button", "list", "template"
    ];
    $whatsapp = $smsGenius->WhatsApp();
    // Send Bulk Messages
    $response = $whatsapp->sendBulkChat($array);
    // Response ( Array )
  • Send Single Message
  • $array = [
          "account" => 1, // Account id
          "recipient" => "+254712123456",
          "type" => "text", // "text", "media", "button", "list", "template"
          "message" => "Hello World!"
    ];
    $whatsapp = $smsGenius->WhatsApp();
    // Send Single Message
    $response = $whatsapp->sendSingleChat($array);
    // Get response ( Array )
  • Start WhatsApp Campaign [ params(campaignID) ]
  • $whatsapp = $smsGenius->WhatsApp();
    // Start WhatsApp Campaign
    $response = $whatsapp->startWhatsAppCampaign("campaignID");
    // Response ( Array )
  • Stop WhatsApp Campaign [ params(campaignID) ]
  • $whatsapp = $smsGenius->WhatsApp();
    // Stop WhatsApp Campaign
    $response = $whatsapp->stopWhatsAppCampaign("campaignID");
    // Response ( Array )