PHPackages                             nessworthy/textmarketer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nessworthy/textmarketer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nessworthy/textmarketer
=======================

An unofficial helper to allow you to send SMS messages using Text Marketer.

1.1.4(3y ago)114.4k↑56.7%1[1 issues](https://github.com/Nessworthy/text-marketer-php-sdk/issues)[1 PRs](https://github.com/Nessworthy/text-marketer-php-sdk/pulls)wtfplPHPPHP &gt;=7.3

Since May 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Nessworthy/text-marketer-php-sdk)[ Packagist](https://packagist.org/packages/nessworthy/textmarketer)[ RSS](/packages/nessworthy-textmarketer/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (3)Versions (8)Used By (0)

Text Marketer PHP SDK [![CircleCI](https://camo.githubusercontent.com/1b4a9a1549226623d6db69ff272f0cc694f286d55c7fcfd4b7a25f688ed5fe7e/68747470733a2f2f646c2e636972636c6563692e636f6d2f7374617475732d62616467652f696d672f67682f4e657373776f727468792f746578742d6d61726b657465722d7068702d73646b2f747265652f6d61737465722e7376673f7374796c653d737667)](https://dl.circleci.com/status-badge/redirect/gh/Nessworthy/text-marketer-php-sdk/tree/master)
====================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#text-marketer-php-sdk-)

An unofficial library-in-progress to assist with text marketer API interactions.

Requirements
------------

[](#requirements)

- PHP 7.3 or higher
- `ext-mbstring`
- `ext-dom`

Composer
--------

[](#composer)

```
composer require nessworthy\textmarketer

```

Example Usage
-------------

[](#example-usage)

- [Setting Up](#setting-up)
- [Creating and Sending SMS Messages](#creating-and-sending-sms-messages)
    - [Scheduling Messages](#scheduling-messages)
    - [Deleting Scheduled Messages](#deleting-scheduled-messages)
- [Handling and Transferring Credits](#handling-and-transferring-credits)
    - [Fetching your Current Credits](#fetching-your-current-credits)
    - [Transferring Credits by Account ID or Credentials](#transferring-credits-by-account-id-or-credentials)
- [Keyword Availability](#keyword-availability)
- [Group Management](#group-management)
    - [Fetching your List of Groups](#fetching-your-list-of-groups)
    - [Adding One or More Numbers to a Group](#adding-one-or-more-numbers-to-a-group)
    - [Creating a New Group](#creating-a-new-group)
    - [Fetching Information for an Existing Group](#fetching-information-for-an-existing-group)
- [Delivery Reports](#delivery-reports)
    - [Filtering by Report Name](#filtering-by-report-name)
    - [Filtering by Report Name and Date Range](#filtering-by-report-name-and-date-range)
    - [Filtering by Report Name and Tag](#filtering-by-report-name-and-tag)
    - [Filtering by Report Name, Tag, and Date Range](#filtering-by-report-name-tag-and-date-range)
- [Account Management](#account-management)
    - [Fetching your Account Information](#fetching-your-account-information)
    - [Fetching Account Information by Account ID](#fetching-account-information-by-account-id)
    - [Updating Your Account Information](#updating-your-account-information)
    - [Creating a New Sub-Account](#creating-a-new-sub-account)
- [Exception and Error Handling](#exception-and-error-handling)

### Setting up

[](#setting-up)

```
$apiCredentials = new \Nessworthy\TextMarketer\Authentication\Simple('api_username', 'api_password');
$httpClient = new \GuzzleHttp\Client();

$textMarketer = new \Nessworthy\TextMarketer\TextMarketer($apiCredentials, $httpClient);
```

#### Parameters

[](#parameters)

- Credentials - An implementation of `\Nessworthy\TextMarketer\Authentication`
- Endpoint (optional) - The text marketer endpoint to use when sending out messages. Should be one of:
    - `\Nessworthy\TextMarketer\TextMarketer::ENDPOINT_PRODUCTION` (default)
    - `\Nessworthy\TextMarketer\TextMarketer::ENDPOINT_SANDBOX`
- HTTP Client (optional) - The HTTP client to send requests out.
    - Expects an implementation of `GuzzleHttp\ClientInterface`
    - By default, an instance of `GuzzleHttp\Client` is used.

### Creating and Sending SMS Messages

[](#creating-and-sending-sms-messages)

```
$messageCommand = new \Nessworthy\TextMarketer\Message\SendMessage(
    'This is a test message', // Your SMS Message.
    ['447777777777'],         // The array of contact numbers.
    'TestCompanyInc',         // Who the message was sent from.
    'testmessage',            // Optional: Tag your message for delivery report filtering.
    24,                       // Optional: Mark the message as time-sensitive: Should only be sent if it is within X hours.
    true,                     // Optional: If true, if any recipient is matched in your STOP group the message will not be sent.
    'myTxtUsEmail@address.com'// Optional: Your txtUS enterprise email (txtUS accounts only).
);

$deliveryResult = $textMarketer->sendMessage($messageCommand);

if ($deliveryResult->isSent()) {
    echo 'Message sent with the ID of ' . $deliveryResult->getMessageId();
} elseif ($deliveryResult->isQueued()) {
    echo 'Message queued with the ID of ' . $deliveryResult->getMessageId();
} elseif ($deliveryResult->isScheduled()) {
    echo 'Is scheduled with the ID of ' . $deliveryResult->getScheduledId();
}
```

#### Scheduling Messages

[](#scheduling-messages)

```
$scheduledDate = (new DateTimeImmutable)->modify('+1 month');
$deliveryResult = $textMarketer->sendScheduledMessage($messageCommand, $scheduledDate);
```

#### Deleting Scheduled Messages

[](#deleting-scheduled-messages)

```
// Scheduled message ID can be found from the delivery result for scheduled messages:
// $scheduledMessageId = $deliveryResult->getScheduledId();
$textMarketer->deleteScheduledMessage($scheduledMessageId);
```

### Handling and Transferring Credits

[](#handling-and-transferring-credits)

#### Fetching your Current Credits

[](#fetching-your-current-credits)

```
echo sprintf('I have %d remaining credits!', $textMarketer->getCreditCount());
```

#### Transferring Credits by Account ID or Credentials

[](#transferring-credits-by-account-id-or-credentials)

```
$transferResult = $textMarketer->transferCreditsToAccountById(100, $someAccountId);

// Or by credentials:

$destinationCredentials = new \Nessworthy\TextMarketer\Authentication\Simple('username', 'password'));
$transferResult = $textMarketer->transferCreditsToAccountByCredentials(100, $destinationCredentials);

echo sprintf(
    'I had %d credits. After transferring, I now have %d!',
    $transferResult->getSourceCreditsBeforeTransfer(),
    $transferResult->getSourceCreditsAfterTransfer()
);
echo '';
echo sprintf(
    'The target account had %d credits. After transferring, it now has %d!',
    $transferResult->getTargetCreditsBeforeTransfer(),
    $transferResult->getTargetCreditsAfterTransfer()
);
```

### Keyword Availability

[](#keyword-availability)

```
$keyword = 'mykeyword';
$keywordAvailability = $textMarketer->checkKeywordAvailability($keyword);

echo sprintf(
    'The keyword "%s" %s available! It %s been recycled (used previously).',
    $keyword,
    ($keywordAvailability->isAvailable() ? 'is' : 'is not'),
    ($keywordAvailability->isRecycled() ? 'has' : 'has not')
);
```

### Group Management

[](#group-management)

#### Fetching Your List of Groups

[](#fetching-your-list-of-groups)

```
$groupCollection = $textMarketer->getGroupsList();

echo sprintf(
    'I have %s groups!',
    $groupCollection->isEmpty() ? 'no' : $groupCollection->getTotal()
);

echo '';
echo 'Here is a summary of each group:';
foreach ($groupCollection->asArray() as $groupSummary) {
    echo sprintf(
        'Group name: %s (ID: %d) has %s numbers. It %s a stop group!',
        $groupSummary->getName(),
        $groupSummary->getId(),
        $groupSummary->getNumberCount(),
        $groupSummary->isStopGroup() ? 'IS' : 'IS NOT'
    );
    echo '';
}
```

#### Adding One or More Numbers to a Group

[](#adding-one-or-more-numbers-to-a-group)

```
$numbersToAdd = new Nessworthy\TextMarketer\Message\Part\PhoneNumberCollection([
    '44700000000',
    '44700000001',
    '44700000002',
]);

$result = $textMarketer->addNumbersToGroup('MyGroupNameOrID', $numbersToAdd);

// Of the numbers - which ones were actually added to the list.
echo 'Added numbers: ' . $textMarketer->getTotalAddedNumbers();
echo 'Numbers added:' . implode('',$textMarketer->getAddedNumbers();
echo '';

// Of the numbers - which ones were not added because they were on a STOP list.
echo 'Stopped numbers: ' . $textMarketer->getTotalStoppedNumbers();
echo 'Numbers added:' . implode('',$textMarketer->getStoppedNumbers();
echo '';

// Of the numbers - which ones were not added because they were already on it.
echo 'Duplicated numbers: ' . $textMarketer->getTotalDuplicateNumbers();
echo 'Numbers added:' . implode('',$textMarketer->getDuplicateNumbers();
```

#### Creating a New Group

[](#creating-a-new-group)

```
$group = $textMarketer->createGroup('mygroup');

echo sprintf(
    'A new group was created by the name "%s" with an assigned ID of "%d"! The group %s a stop group.',
    $group->getName(),
    $group->getId(),
    $group->isStopGroup() ? 'IS' : 'IS NOT'
);

// You can also use getNumberCount() and getNumbers(), which will return 0 and an empty array, respectively.
```

#### Fetching Information for an Existing Group

[](#fetching-information-for-an-existing-group)

```
$group = $textMarketer->getGroupInformation('mygroup');

echo sprintf(
    'The group is called "%s" with an assigned ID of "%d"! The group %s a stop group.',
    $group->getName(),
    $group->getId(),
    $group->isStopGroup() ? 'IS' : 'IS NOT'
);

echo '';

echo sprintf(
    'The group has %d numbers. Here they are:%s',
    $group->getNumberCount(),
    implode('', $group->getNumbers())
);
```

### Delivery Reports

[](#delivery-reports)

```
$reportCollection = $textMarketer->getDeliveryReportList();

echo sprintf(
    'I have %s reports in total!',
    $reportCollection->isEmpty() ? 'no' : $reportCollection->getTotal()
);

foreach ($reportCollection->asArray() as $report) {
    echo '';
    echo sprintf(
        'Report %s (last updated: %s) has extension %s.',
        $report->getName(),
        $report->getLastUpdated->format('d-m-Y H:i:s'),
        $report->getExtension()
    );
}
```

All report-related calls return the results in the same format as above.

#### Filtering by Report Name

[](#filtering-by-report-name)

```
$reportCollection = $textMarketer->getDeliveryReportListByName('ReportName');
```

#### Filtering By Report Name and Date Range

[](#filtering-by-report-name-and-date-range)

```
$from = new DateTimeImmutable();
$to = $from->modify('-1 week');
$dateRange = new \Nessworthy\TextMarketer\DateRange($from, $to);
$reportCollection = $textMarketer->getDeliveryReportListByNameAndDateRange('ReportName', $dateRange);
```

#### Filtering by Report Name and Tag

[](#filtering-by-report-name-and-tag)

```
$from = new DateTimeImmutable();
$reportCollection = $textMarketer->getDeliveryReportListByNameAndTag('ReportName', 'mytag');
```

#### Filtering by Report Name, Tag, and Date Range

[](#filtering-by-report-name-tag-and-date-range)

```
$from = new DateTimeImmutable();
$to = $from->modify('-1 week');
$dateRange = new \Nessworthy\TextMarketer\DateRange($from, $to);
$reportCollection = $textMarketer->getDeliveryReportListByNameTagAndDateRange('ReportName', 'mytag', $dateRange);
```

### Account Management

[](#account-management)

All methods here return an instance of `Nessworthy\TextMarketer\Account\AccountInformation`. These objects contain both account and API credentials - it would be wise to not cache or otherwise save them as-is!

#### Fetching Your Account Information

[](#fetching-your-account-information)

```
$accountInformation = $textMarketer->getAccountInformation();

echo 'Account ID: ' . $accountInformation->getId();
echo 'Company Name: ' . $accountInformation->getCompanyName();
echo 'Account Created At: ' . $accountInformation->getCreatedDate()->format('d/m/Y H:i:s');
echo 'Remaining Credits: ' . $accountInformation->getRemainingCredits();
echo 'Notification Email: ' . $accountInformation->getNotificationEmail();
echo 'Notification Mobile Number: ' . $accountInformation->getNotificationMobile();
echo 'Account Username: ' . $accountInformation->getUiUserName();
echo 'Account Password: ' . $accountInformation->getUiPassword();
echo 'API Username: ' . $accountInformation->getApiUserName();
echo 'API Password: ' . $accountInformation->getApiPassword();
```

#### Fetching Account Information by Account ID

[](#fetching-account-information-by-account-id)

Note: The account ID should be typed as a string.

```
$accountInformation = $textMarketer->getAccountInformationForAccountId($accountId);
```

#### Updating Your Account Information

[](#updating-your-account-information)

Note: There's no way to update another account's information - you must use their credentials.

All of the fields for `UpdateAccountInformation` are optional - pass `null` when you don't want to change a particular field.

Certain restrictions apply when updating your account information. [See here for what you can use](https://wiki.textmarketer.co.uk/display/DevDoc/account+POST+method).

```
$newAccountDetails = new Nessworthy\TextMarketer\Account\UpdateAccountInformation(
    'uiusername',               // The new UI Username.
    'uipassword',               // The new UI Password.
    'apiusername',              // The new API Username.
    'apipassword',              // The new API Password.
    'Company Name',             // The new company name.
    'notification@email.com',   // The new notification email address.
    '447000000000',             // The new notification mobile number.
);

$updatedAccountInformation = $textMarketer->updateAccountInformation($newAccountDetails);
```

#### Creating a New Sub-Account

[](#creating-a-new-sub-account)

Note: Creating new account is disabled by default - you will need to contact TextMarketer to enable this. Like updating your account, you must at least provide a notification email address OR a notification mobile number

These fields are subject to the same restrictions as that when updating you account information.

```
$subAccount = new Nessworthy\TextMarketer\Account\CreateSubAccount(
    'uiusername',              // The new account's username
    'uipassword',              // Optional: The new account's password. If null is given, a random password will be generated.
    'Company Name',            // The new account's company name.
    'notification@email.com',  // Optional: The new account's notification email address.
    '447000000000',            // Optional: The new account's notification mobile number.
    false,                     // Whether to use the same pricing as the parent account.
    'PROMOCODE'                // Optional: A promo code for the account if you have one.
);
```

### Exception and Error Handling

[](#exception-and-error-handling)

```
// All exceptions extend \Nessworthy\TextMarketer\TextMarketerException.
try {
    // Send a text marketer request.
} catch (\Nessworthy\TextMarketer\Endpoint\EndpointException $e) {
    // $e->getMessage() and $e->getCode() return the first message & message code.
    // Or for all errors...
    foreach ($e->getAllEndpointErrors() as $error) {
        error_log(sprintf('TextMarketer Message Error: [%s] %s', $error->getCode(), $error->getMessage()));
    }
}
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 98.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~319 days

Recently: every ~202 days

Total

6

Last Release

1366d ago

PHP version history (4 changes)1.0.1PHP &gt;=7.1

1.1.2PHP &gt;=7.2

1.1.3PHP &gt;=7.2.5

1.1.4PHP &gt;=7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12972?v=4)[Sean Mountcastle](/maintainers/Sean)[@sean](https://github.com/sean)

---

Top Contributors

[![Nessworthy](https://avatars.githubusercontent.com/u/1154344?v=4)](https://github.com/Nessworthy "Nessworthy (61 commits)")[![jmsfwk](https://avatars.githubusercontent.com/u/9892048?v=4)](https://github.com/jmsfwk "jmsfwk (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nessworthy-textmarketer/health.svg)

```
[![Health](https://phpackages.com/badges/nessworthy-textmarketer/health.svg)](https://phpackages.com/packages/nessworthy-textmarketer)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M45](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[oat-sa/tao-core

TAO core extension

66143.7k124](/packages/oat-sa-tao-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
