Download the PHP package cmtelecom/messaging-php without Composer

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

CM Messaging SDK

Packagist Packagist Travis

Note: This project is not maintained anymore. Please use https://github.com/cmdotcom/text-sdk-php instead.

PHP SDK for easy use of CM messaging services. Built with an easy syntax your SMS, Push and/or Voice messages and send them directly with the CM services.

Simple example

Requirements

composer require cmtelecom/messaging-php

And

composer require php-http/guzzle6-adapter

*When using an alternative HttpClient you don't have to add the Guzzle adapter dependency but it is recommended to use Guzzle. For advanced usage and other http clients you can look at http://docs.php-http.org/en/latest/clients.html.

Usage

Instantiate client with your product token, which can be found on the Gateway app when you login to https://gateway.cmtelecom.com.

Building a messages

To create a message you can use an easy one-liner. The required properties are from, to and body. All others can be set optional.

Sending a message

After building a message you can send it as following.

Sending a batch of messages

When you send a batch of messages, this is when you have multiple messages with different body's. You can send all of them in one request by making an array of messages. If the body is the same for all recipients you can simply add the array with the recipients phone numbers in the setTo(), you won't have to make multiple messages is this case (as shown in the simple example).

Handle response

After sending a message you get a response back that contains the accepted and failed messages. This way you can validate if the messages are processed as expected. You can do this for all messages or optionally add a phone number or an array of phone numbers to check those specific messages.

For more detailed error handling you can optionally catch RequestException, HttpException and/or NetworkException which are child's of the more generic TransferException exception.

It is also possible to retrieve the PSR-7 response, this can be done with getResponse(). The response body content can be retrieved with getResponse()->getBody()->getContents().

Advanced usage

Default properties

If you call multiple times the $client->send() method and you want certain properties for all messages send in your application you can set these properties on the $client. Properties set in the Message will still overwrite the properties set in $client.

Strategies

By default this SDK will remove duplicate phone numbers within the same message because it is assumed you don't wan't to send the exact same message twice to the same phone number at the same time. If you wan't to disable this strategy/behaviour you can add the following to you send() method.

Configuration Exceptions

Exception thrown Description
InvalidConfigurationException The configuration is not valid
└ InvalidAllowedChannelException One or more AllowedChannel(s) is not a valid option
└ InvalidStrategyException One or more stratagie(s) is not a valid option

Http Exceptions

Status code Exception thrown Description
null TransferException Something unexpected happened
null RequestException The request is invalid
    └ 400-499 HttpException Client-side error
       └ 400 BadRequestException The request failed because of an invalid value, all messages has not been send
    └ 500-599 NetworkException Server-side error

Methods

Client

Method Parameters Return
__construct() $productToken, HttpClient $httpClient void
send() array/Message $messages, array/null $parameters Response
getBodyType() BodyType
setBodyType() BodyType $bodyType $this
getDcs() int
setDcs() int $dcs $this
getReference() string
setReference() string $reference $this
getCustomGrouping1() string
setCustomGrouping1() string $reference $this
getCustomGrouping2() string
setCustomGrouping2() string $reference $this
getCustomGrouping3() string
setCustomGrouping3() string $reference $this
getMinimumNumberOfMessageParts() int
setMinimumNumberOfMessageParts() int $minimumNumberOfMessageParts $this
getMaximumNumberOfMessageParts() int
setMaximumNumberOfMessageParts() int $minimumNumberOfMessageParts $this
getAppKey() string
setAppKey() string $appKey $this
getAllowedChannels() array
setAllowedChannels() array/AllowedChannel $allowedChannels $this
getProductToken() string

Message

Method Parameters Return
getFrom() array
setFrom() string $from $this
getTo() array
setTo() array/string $to $this
getBody() string
setBody() string $body, BodyType/null $bodyType $this
getDcs() int
setDcs() int $dcs $this
getReference() string
setReference() string $reference $this
getCustomGrouping1() string
setCustomGrouping1() string $reference $this
getCustomGrouping2() string
setCustomGrouping2() string $reference $this
getCustomGrouping3() string
setCustomGrouping3() string $reference $this
getMinimumNumberOfMessageParts() int
setMinimumNumberOfMessageParts() int $minimumNumberOfMessageParts $this
getMaximumNumberOfMessageParts() int
setMaximumNumberOfMessageParts() int $minimumNumberOfMessageParts $this
getAppKey() string
setAppKey() string $appKey $this
getAllowedChannels() array
setAllowedChannels() array/AllowedChannel $allowedChannels $this
getProductToken() string

Response

Method Parameters Return
getDetails() string
getAccepted() array/string/null $phoneNumbers array /null
isAccepted() array/string/null $phoneNumbers bool
getFailed() array/string/null $phoneNumbers array/null
isFailed() array/string/null $phoneNumbers bool
getResponse() PSR-7 Response

Todo


All versions of messaging-php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
myclabs/php-enum Version 1.5.*
php-http/httplug Version 2.1.*
guzzlehttp/psr7 Version 1.6.*
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 cmtelecom/messaging-php contains the following files

Loading the files please wait ....