PHP code example of yeboahnanaosei / fayasms

1. Go to this page and download the library: Download yeboahnanaosei/fayasms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yeboahnanaosei / fayasms example snippets



use yeboahnanaosei\FayaSMS\FayaSMS;

rom FayaSMS
$appSecret = "app_secret";  // Obtained from FayaSMS
$senderID  = "sender_id";   // Obtained from FayaSMS

// Create an instance of FayaSMS and supply your appKey, appSecret and senderID.
$fayasms = new FayaSMS($appKey, $appSecret, $senderID);

// Set the recipient phone number. The recipient number must comply with FayaSMS
// telephone rules. Meaning the number must be in international format.
// Read more from FayaSMS.com
$fayasms->setRecipient("23326XXXXXXX");

// Set the body of the message
$fayasms->setMessageBody("Message to be sent to the recipient");

// Then you just send. This will return a JSON payload from FayaSMS indicating
// whether your message was sent successfully or otherwise
$response = $fayasms->send();


use yeboahnanaosei\FayaSMS\FayaSMS;

rom FayaSMS
$appSecret = "app_secret";  // Obtained from FayaSMS
$senderID  = "sender_id";   // Obtained from FayaSMS

// Create an instance of FayaSMS and supply your appKey, appSecret and senderID
$fayasms = new FayaSMS($appKey, $appSecret, $senderID);

// For bulk messages you have two methods you can use to set the recipients. Choose
// whichever one you prefer

// The first one is this:
// Just provide a string of phone numbers separated by comma.
// The numbers must comply with FayaSMS telephone rules. Meaning each number must
// be in international format. Read more from FayaSMS.com
$fayasms->setRecipient("23326XXXXXXX, 23324XXXXXXX, 23327XXXXXXX");

// The other option is this:
// Instead of a string, you just supply an array of phone numbers by calling the
// setRecipientsByArray() method. The numbers must be in international format
$recipients = ["23326XXXXXXX", "23324XXXXXXX", "23327XXXXXXX"];
$fayasms->setRecipientsByArray($recipients);

// Set the body of the message
$fayasms->setMessageBody("Message to be sent to recipients");

// Then you just send. This will return a JSON payload from FayaSMS indicating
// whether your message was sent successfully or otherwise
$response = $fayasms->send();


use yeboahnanaosei\FayaSMS\FayaSMS;

rom FayaSMS
$appSecret = "app_secret";  // Obtained from FayaSMS

// Create an instance of FayaSMS and supply your appKey, appSecret
// Your senderID is not = "23326XXXXXXX, 23355XXXXXXX";

$fayasms->setRecipient($recipients);
$fayasms->setMessageBody($message);

// Request for the estimate.
// Returns a JSON payload indicating how many units such a message will cost
$fayasms->getEstimate();


use yeboahnanaosei\FayaSMS\FayaSMS;

rom FayaSMS
$appSecret = "app_secret";  // Obtained from FayaSMS

// Create an instance of FayaSMS and supply your appKey, appSecret
$fayasms = new FayaSMS($appKey, $appSecret);

// The getMessages() method returns JSON data holding all messages sent using
// your appKey and appSecret
$messages = $fayasms->getMessages();


use yeboahnanaosei\FayaSMS\FayaSMS;

rom FayaSMS
$appSecret = "app_secret";  // Obtained from FayaSMS

// Create an instance of FayaSMS and supply your appKey, appSecret
$fayasms = new FayaSMS($appKey, $appSecret);

// The getMessage($messageID) method expects a message id and returns JSON data
// holding all messages sent using your appKey and appSecret
$message = $fayasms->getMessage($messageID);


use yeboahnanaosei\FayaSMS\FayaSMS;

rom FayaSMS
$appSecret = "app_secret";  // Obtained from FayaSMS

// Create an instance of FayaSMS and supply your appKey, appSecret
$fayasms = new FayaSMS($appKey, $appSecret);

// Call the getBalance() method to find out your remaining balance. Returns a JSON payload
$balance = $fayasms->getBalance();



use yeboahnanaosei\FayaSMS\FayaSMS;

rom FayaSMS
$appSecret = "app_secret";  // Obtained from FayaSMS

// Create an instance of FayaSMS and supply your appKey, appSecret
$fayasms = new FayaSMS($appKey, $appSecret);

// Call the getSenderIDs() method to get all your sender IDs.
//Returns a JSON payload
$senderIDs = $fayasms->getSenderIDs();


use yeboahnanaosei\FayaSMS\FayaSMS;

rom FayaSMS
$appSecret = "app_secret";  // Obtained from FayaSMS

// Create an instance of FayaSMS and supply your appKey, appSecret
$fayasms = new FayaSMS($appKey, $appSecret);

// To request a new sender ID of course you need the new sender ID you want and
// a description for the new sender id
$senderID = "new_sender_id";
$description = "Description for my new sender id";

// Returns a JSON payload indicating that your request has been submitted for
// review
$newSenderID = $fayasms->requestSenderID($senderID, $description);