Download the PHP package emanate/beem without Composer

On this page you can find all versions of the php package emanate/beem. 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 beem

Beem Africa

Beem Africa SMS for Laravel

Latest Stable Version Total Downloads Monthly Downloads License

A Laravel package for the Beem Africa messaging APIs. It covers:

This is a community package. It is not affiliated with Beem Africa.

Contents

Requirements

Installation

Publish the config file:

When upgrading, compare your published config/beem.php with the package's copy. New options are added over time.

Configuration

Every option can be set from .env. Only the first three are needed to send SMS:

See config/beem.php for the full list, with comments.

Authentication

By default every request uses HTTP Basic auth, with your API key as the username and your secret as the password.

Beem also accepts an access token, sent in the Authorization header without a Bearer prefix. Set BEEM_ACCESS_TOKEN and the token replaces the key and secret everywhere. The key and secret can then be left empty.

You can also set credentials at runtime:

Call withoutAccessToken() to fall back to key and secret auth for a single call.

SMS

Sending

Use the facade or the beem() helper:

There are three ways to add recipients:

Numbers are in international format without the +, for example 255700000000.

Message options

Reading the response

send() returns the raw PSR-7 response. sendAndParse() returns the decoded body, and throws when Beem answers with an error code:

Delivery reports

Beem does not push delivery reports for local SMS. You poll for them using the request_id returned by a send. Wait at least five minutes after sending, so the mobile operator has time to report back:

status is one of PENDING, DELIVERED or UNDELIVERED.

Balance

Sender names

Supported filters: page, limit, sortBy, sortOrder, q, status. Sender IDs are registered in the Beem dashboard; the API only lists them.

Templates

Error handling

Every method that returns a decoded array throws Emanate\BeemSms\Exceptions\BeemApiException when Beem answers with an error. That covers balance, deliveryReport, senderNames, the template methods and sendAndParse. The exception code is Beem's response code, and BeemApiException::RESPONSE_CODES maps every documented code to its meaning.

Two-Way SMS

Beem POSTs mobile-originated messages to a callback URL that you register on your Two-Way number in the Beem dashboard. Enable the route:

Register this URL with Beem:

Then listen for the event:

The route answers with the acknowledgement Beem expects, {"transaction_id": "...", "successful": true}, as soon as the event is dispatched. Do slow work in a queued listener. Beem may retry, so use transactionId() to skip messages you have already processed.

Securing the callback

Every callback is authenticated before the payload is read. Beem's docs do not say which credentials, if any, it sends with the callback, so several are accepted:

  1. ?token= on the callback URL, or an Authorization header, equal to BEEM_TWO_WAY_TOKEN (recommended)
  2. an Authorization header equal to your access_token
  3. HTTP Basic auth carrying your API key and secret

Comparisons are constant-time, and a Bearer or Token prefix is tolerated. Unauthenticated requests get a 401 and dispatch no event. Your API secret and access token are never accepted in the query string, so they cannot leak into access logs.

If you authenticate the callback elsewhere, for example at an API gateway, set two_way.verify_credentials to false. Leave it on otherwise. With it off, anyone who learns the URL can inject fake messages.

Extra middleware for the route goes in two_way.middleware. The credential check always applies on top.

OTP

The OTP API uses your SMS API key and secret, but runs on its own host. Create an OTP application in the Beem dashboard and set its ID:

verify() throws Emanate\BeemSms\Exceptions\OtpException when the PIN is wrong, expired, already used, or out of attempts. Use check() if you want a boolean instead:

OtpException::RESPONSE_CODES maps codes 100–118 to their meanings. The app ID and credentials can be set per call:

The channel, SMS or WhatsApp, is set on the OTP application in the dashboard.

Request field names. Beem's OTP reference documents the responses and codes, but not the request body. This package sends appId and msisdn to request a PIN, and pinId and pin to verify one. If Beem expects something else, add any field with parameter():

Multicountry SMS

Multicountry SMS is a separate Beem platform. It has its own host, authenticates with a username and password, and takes uppercase form parameters.

The platform takes one destination per request. Loop to send to many.

Binary, UDH and concatenation

Any other platform parameter can be set directly. The name is uppercased for you:

Inbound messages and delivery reports

The platform POSTs inbound messages and delivery reports to one callback URL, as form fields. The platform sends no credentials, so the package protects the route with a secret token in the URL. Enable the route:

Your callback URL is:

Listen for the events. An inbound message listener:

A delivery report listener:

A request carrying a STATUS field is treated as a delivery report. Anything else is treated as an inbound message. The route answers with the empty HTTP 200 the platform expects. Requests with a missing or wrong token get a 401. If no token is configured, every request gets a 401, so the route is never left open by accident. Set multicountry.callback.verify_token to false only if you authenticate the route some other way.

Balance

Error handling

The platform answers HTTP 200 even when a send fails. send() checks the status in the body and throws Emanate\BeemSms\Exceptions\MulticountrySmsException for any non-zero status. The exception code is the platform status, and MulticountrySmsException::STATUS_CODES maps every documented code to its meaning.

Phone number validation

If a number is not in a format Beem accepts, the whole send fails. With validate_phone_addresses set to true (the default), numbers are checked before sending and an exception is thrown for invalid ones.

To use your own rules, point validator_class in the config at a class that implements Emanate\BeemSms\Contracts\Validator.

Testing

Changelog

See CHANGELOG.

Contributing

Issues and pull requests are welcome at wao1ook/beem. Please run composer test and composer pint before opening a pull request.

Security vulnerabilities

Please review our security policy to report a vulnerability.

Credits

License

The MIT License (MIT). See License File for details.


All versions of beem with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-curl Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.8|^8.0
illuminate/support Version ^12.0|^13.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 emanate/beem contains the following files

Loading the files please wait ...