Skip to content

Latest commit

 

History

History
78 lines (62 loc) · 1.88 KB

03.texts.md

File metadata and controls

78 lines (62 loc) · 1.88 KB

Texts

Send a Text Individually

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
}

Sending Multiple Texts with The Same Message

<?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
}

List Received Texts for a Number

<?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;
    }
}