Download the PHP package sms-partners/php-sdk without Composer

On this page you can find all versions of the php package sms-partners/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-sdk

SMS Partners PHP SDK

Official PHP SDK for the SMS Partners API.

Requirements

Installation

Getting Started

Generate an API key from the Developer → API Tokens section of your SMS Partners account, then create a client:


Sending SMS

With a custom Sender ID

Pass an approved Sender ID as the from argument to control how the message appears to the recipient:

The from value must match an approved Sender ID on your account. If omitted, the message is sent from the shared number pool.

Scheduling a message

Pass a \DateTimeInterface as scheduledAt to send the message at a future time. Credits are reserved immediately.

Credit cost

Credits are consumed based on message length and character encoding:

Encoding Single SMS Per segment (multipart)
GSM-7 (standard ASCII) 160 chars 153 chars
Unicode (emoji, non-Latin) 70 chars 67 chars

A single message can be up to 1,600 characters. Long messages are split into multiple segments and charged per segment.

SendResponse properties

SendResponse extends Message and adds a convenience to property.

Property Type Description
id int Message ID
status string sending, scheduled, sent, failed
body string Message body
from ?string Sender ID name or pool number used
scheduledAt ?DateTimeImmutable Scheduled send time, or null
creditsUsed int Credits deducted
createdAt DateTimeImmutable When the message was created
recipients Recipient[] Delivery status per recipient
to string Convenience — phone of the first recipient

Credit Balance

Quickly check the current balance without fetching the full account object:


Messages

List messages

Retrieve your outbound message history, newest first. Results are paginated at 25 per page.

Filter by status

Available statuses: scheduled, queued, sending, sent, failed, cancelled.

Get a single message

Message properties

Property Type Description
id int Message ID
status string Current message status
body string Message body
from ?string Sender ID name or pool number used
scheduledAt ?DateTimeImmutable Scheduled send time, or null
creditsUsed int Credits charged
createdAt DateTimeImmutable When the message was created
recipients Recipient[] Delivery status per recipient

Recipient properties

Property Type Description
phone string Recipient phone number
status string queued, sent, delivered, or failed
deliveredAt ?DateTimeImmutable Delivery confirmation time, or null
errorMessage ?string Failure reason, or null

MessagePage properties

Property Type Description
data Message[] Messages on this page
total int Total messages across all pages
perPage int Page size (25)
currentPage int Current page number
lastPage int Last page number
hasMore() bool Whether more pages exist

Sender IDs

List all approved Sender IDs on your account. These are the values you can pass as from when sending:

SenderId properties

Property Type Description
id int Sender ID record ID
name string The sender name (use this as the from value)
status string Always approved

Account

Fetch your full account details:

AccountResponse properties

Property Type Description
id int Account user ID
name string Account holder name
email string Account email address
balanceCredits int Current credit balance
status string active or suspended
autoTopupEnabled bool Whether auto top-up is active
autoTopupThreshold int Balance level that triggers top-up
autoTopupAmount int Credits purchased on auto top-up

Webhooks

SMS Partners can send webhook events to your server when a message is delivered or fails. Configure webhook endpoints from the Developer → Webhooks section of your account.

Verifying signatures

Every webhook request includes an X-Webhook-Signature header containing an HMAC-SHA256 signature of the raw request body. Always verify this before processing:

Parsing events

After verifying the signature, parse the payload into a typed event object:

Handling specific events

Full webhook handler example

WebhookEvent reference

Property / Method Type Description
event string message.delivered or message.failed
timestamp DateTimeImmutable When the event occurred
data array Full event payload
isDelivered() bool True for message.delivered events
isFailed() bool True for message.failed events
messageId() ?int ID of the related message
recipientPhone() ?string Recipient phone number

Error Handling

All SDK methods throw exceptions that extend SmsPartners\Exceptions\SmsPartnersException. Catch the base class to handle all errors, or catch specific types for fine-grained control:

Exception reference

Exception Thrown when
AuthenticationException API key is invalid or missing (HTTP 401)
InsufficientCreditsException Insufficient credits (HTTP 402). Exposes balance and required.
ValidationException Request failed validation (HTTP 422). Exposes errors keyed by field name.
ApiException Unexpected API error. Exposes statusCode.
SmsPartnersException Base class — also thrown for connection failures.

Configuration

Custom base URL

If you are using a self-hosted or staging instance, pass a custom base URL as the second argument:


Testing

In your test suite, use Guzzle's MockHandler to intercept HTTP requests without hitting the real API:


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sms-partners/php-sdk contains the following files

Loading the files please wait ...