1. Go to this page and download the library: Download oxemis/oxisms 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/ */
oxemis / oxisms example snippets
use \Oxemis\OxiSms\OxiSmsClient;
// getenv will allow us to get the OXISMS_API_LOGIN/OXISMS_API_PWD variables we created before:
$apilogin = getenv('OXISMS_API_LOGIN');
$apipwd = getenv('OXISMS_API_PWD');
$oxisms = new OxiSmsClient($apilogin, $apipwd);
// or, without using environment variables:
$apilogin = 'your API login';
$apipwd = 'your API password';
$oxisms = new OxiSmsClient($apilogin, $apipwd);
use Oxemis\OxiSms\OxiSmsClient;
use Oxemis\OxiSms\Objects\Message;
// Create the Client
$apilogin = 'your API login';
$apipwd = 'your API password';
$client = new OxiSmsClient($apilogin, $apipwd);
// Define the message
$message = new Message();
$message
->addRecipientPhoneNumber("+33666666666")
->setMessage("Hi there ! This is my first SMS sent with the awesome oxisms-php library !");
// Send the message
$client->sendAPI->send($message);
use Oxemis\OxiSms\Objects\Recipient;
use Oxemis\OxiSms\Objects\Message;
use Oxemis\OxiSms\OxiSmsClient;
// First of all, we need recipients with meta data
$myFirstRecipient = new Recipient();
$myFirstRecipient->setPhoneNumber("+33666666666");
$myFirstRecipient->setMetaData(["Name" => "Joe", "ID" => 1]);
$mySecondRecipient = new Recipient();
$mySecondRecipient->setPhoneNumber("+3377777777");
$mySecondRecipient->setMetaData(["Name" => "Jane", "ID" => 2]);
// We create the message with {{custom parts}}
$m = new Message();
$m->addRecipient($myFirstRecipient)
->addRecipient($mySecondRecipient)
->setMessage("Hi {{Name}} ! This is your ID : {{ID}}");
// Then we send the two messages in one call !
$client = new OxiSmsClient(API_LOGIN, API_PWD);
$client->sendAPI->send($m);
use Oxemis\OxiSms\OxiSmsClient;
use Oxemis\OxiSms\Objects\Message;
// Define the message
$message = new Message();
$message
->setSender("OxiSMS")
->addRecipientPhoneNumber("+33666666666")
->setMessage("Hi there ! This is my first SMS sent with the awesome oxisms-php library !");
// Send the message
$client = new OxiSmsClient(API_LOGIN, API_PWD);
$client->sendAPI->send($message);
// Compute the cost of the message (without sending it !)
$s = $client->sendAPI->getCostOfMessage($message );
// You'll get a Sending structure (without Ids, because messages are not really sent)
echo "This sending will consume " . $s->getTotalCost() . " credit(s).";
$message = new \Oxemis\OxiSms\Objects\Message();
$message
->setSender("OxiSMS")
->addRecipientPhoneNumber("+33666666666")
->addRecipientPhoneNumber("+33777777777")
->setMaxCreditsPerSending(1)
->setMessage("Hi there ! This is my first SMS sent with the awesome oxisms-php library !");
// Will throw an OxiSmsException :
// Code : 406
// Message : Total credits needed to send the message (2) exceeds the MaxCreditsPerSending parameter (1).
$client->sendAPI->send($message);
$message = new \Oxemis\OxiSms\Objects\Message();
$message
->setStrategy(Message::STRATEGY_NOTIFICATION)
->addRecipientPhoneNumber("+33666666666")
->setMessage("Here is your code to authenticate : " . $twoFactorsCode);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.