1. Go to this page and download the library: Download prinx/txtconnect 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/ */
prinx / txtconnect example snippets
use Prinx\Txtconnect\Sms;
$message = 'Hello World';
$number = '233...'; // See number formats below
$sms = new Sms;
$response = $sms->send($message, $number);
use Prinx\Txtconnect\Sms;
$method = 'POST'; // GET|POST
$sms = new Sms;
$response = $sms->send($message, $phone, $method);
$sms = new Sms();
$sms->to('233200000000');
$sms->to('233200000000');
$sms->to('233220000002');
$message = 'Hi';
$response = $sms->keepDuplicate()->send($message); // Sends to the first number twice then the third number.
$sms = new Sms();
$sms->to('233200000000');
$sms->to('233200000000');
$sms->to('233220000002');
$message = 'Hi';
$response = $sms->removeDuplicate()->send($message); // Sends to only two
$sms = new Sms();
$response = $sms->asUnicode()->send('Hi 😄', '233200000000');
$sms = new Sms();
$response = $sms->asPlainText()->send('Hi', '233200000000');
$sms = new Sms();
$response = $sms->send('Hi', '233200000000'); // $response is an SmsResponse instance
// If request received by TXTCONNECT
if ($response->isBeingProcessed()) {
$batchNumber = $response->getBatchNumber();
$statusCheckUrl = $response->getStatusCheckUrl();
$availableBalance = $response->getBalance();
// ...
} else {
$error = $response->getError();
$rawResponse - $response->getRawResponse();
// ...
}
$sms = new Sms();
$phone1 = '233200000000';
$phone2 = '233210000001';
$phone3 = '233220000002';
$response = $sms->send('Hi', [$phone1, $phone2, $phone3]); // $response is a SmsResponseBag instance
// Response for the first phone number
$response1 = $response->get($phone1);
if ($response1->isBeingProcessed()) {
$batchNumber = $response1->getBatchNumber();
$statusCheckUrl = $response1->getStatusCheckUrl();
$availableBalance = $response1->getBalance();
// ...
} else {
$error = $response1->getError();
$rawResponse - $response1->getRawResponse();
// ...
}
$response2 = $response->get($phone2);
// ...
$response3 = $response->get($phone3);
//...
$sms = new Sms();
$response = $sms->asBag()->send('Hi', '233200000000'); // Will return a SmsResponseBag
$smsResponse = $response->first();
if ($smsResponse->isBeingProcessed()) {
// code
}
use Prinx\Txtconnect\SmsStatus;
$status = new SmsStatus();
$sms = $status->of($batchNumber)->get(); // Return an instance of SmsMessage
$isDelivered = $sms->isDelivered(); // Returns true if SMS has been delivered to recipient.
$allFetchedStatuses = $status->all(); // Array of SmsMessage
$allFetchedStatusesAsArray = $status->toArray();
$numberOfStatusesFetched = $status->count();
use Prinx\Txtconnect\Balance;
$balance = new Balance();
$amount = $balance->amount();
use Prinx\Txtconnect\Inbox;
$inbox = new Inbox();
$inboxCount = $inbox->count(); // Number of SMS in the fetched Inbox.
$allSmsToArray = $inbox->toArray(); // An array of all inbox SMS, each SMS being an array
$allSms = $inbox->all(); // Array of all inbox SMS, each SMS being a SmsMessage instance
$allSms = $inbox->get($phone); // Get an array of all SMS sent to this phone number
$sms = $inbox->nth(2); // Return the second SmsMessage of the inbox
$inbox->refresh(); // Prepare the inbox to be refetched.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.