The following example demonstrates the use of the Text service instead of the
Broadcast service for sending batches of texts.
Note that you cannot send a message from a number to itself. Although the operation
may succeed, the text will not be delivered.
<?php
use CallFire\Api\Rest\Request;
use CallFire\Api\Rest\Response;
require 'vendor/autoload.php';
$client = CallFire\Api\Client::Rest("<api-login>", "<api-password>", "Text");
$request = new Request\SendText;
$request->setFrom('15551231234');
$request->setTo('15551231235');
$request->setMessage('Test API Text');
$response = $client->SendText($request);
$result = $client::response($response);
if($result instanceof ResourceReference) {
// Success
}
<?php
use CallFire\Api\Rest\Request;
use CallFire\Api\Rest\Response;
require 'vendor/autoload.php';
$client = CallFire\Api\Client::Rest("<api-login>", "<api-password>", "Text");
$request = new Request\SendText;
$request->setFrom('15551231234');
$request->setTo(array(
'15551231235',
'15551231236',
'15551231237',
'15551231238'
));
$request->setMessage('Test API Text');
$response = $client->SendText($request);
$result = $client::response($response);
if($result instanceof ResourceReference) {
// Success
}
<?php
use CallFire\Api\Rest\Request;
use CallFire\Api\Rest\Response;
require 'vendor/autoload.php';
$client = CallFire\Api\Client::Rest("<api-login>", "<api-password>", "Text");
$request = new Request\QueryTexts;
$request->setToNumber('15551231234');
$response = $client->QueryTexts($request);
$result = $client::response($response);
if($result instanceof ResourceList) {
foreach($result as $text) {
echo "[{$text->getCreated()}] {$text->getFromNumber()}: {$text->getMessage()}".PHP_EOL;
}
}