All Projects → cmdotcom → text-sdk-php

cmdotcom / text-sdk-php

Licence: MIT license
PHP SDK to send messages with CM.com

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to text-sdk-php

messaging-apis
Messaging APIs for multi-platform
Stars: ✭ 1,759 (+9672.22%)
Mutual labels:  line, messaging, viber
Messaging Apis
Messaging APIs for multi-platform
Stars: ✭ 1,754 (+9644.44%)
Mutual labels:  line, messaging, viber
Bottender
⚡️ A framework for building conversational user interfaces.
Stars: ✭ 3,803 (+21027.78%)
Mutual labels:  line, messaging, viber
Notify
A dead simple Go library for sending notifications to various messaging services.
Stars: ✭ 727 (+3938.89%)
Mutual labels:  line, messaging, whatsapp
Webapp
Tinode web chat using React
Stars: ✭ 156 (+766.67%)
Mutual labels:  messaging, whatsapp
Vonage Ruby Sdk
Vonage REST API client for Ruby. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 203 (+1027.78%)
Mutual labels:  messaging, sms
Sms Bomber
A very, very simple sms bomber written in python and now java. You can adjust the amount of texts sent, and the interval at which they are sent (if you want any). For educational purposes only.
Stars: ✭ 91 (+405.56%)
Mutual labels:  text, sms
Vonage Python Sdk
Vonage Server SDK for Python. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 134 (+644.44%)
Mutual labels:  messaging, sms
Integrations
Connect your App to Multiple Messaging Channels with the W3C Open standard.
Stars: ✭ 721 (+3905.56%)
Mutual labels:  line, messaging
Claudia Bot Builder
Create chat bots for Facebook Messenger, Slack, Amazon Alexa, Skype, Telegram, Viber, Line, GroupMe, Kik and Twilio and deploy to AWS Lambda in minutes
Stars: ✭ 1,717 (+9438.89%)
Mutual labels:  line, viber
numspy
A python module for sending free sms as well as finding details of mobile number via website Way2sms.
Stars: ✭ 57 (+216.67%)
Mutual labels:  messaging, sms
Tindroid
Tinode chat client application for Android
Stars: ✭ 194 (+977.78%)
Mutual labels:  messaging, whatsapp
Q Municate Ios
Q-municate iOS repository
Stars: ✭ 164 (+811.11%)
Mutual labels:  messaging, whatsapp
nodemessage
interact with your local iMessage database
Stars: ✭ 39 (+116.67%)
Mutual labels:  messaging, imessage
ChristmasSpiritBreaker-andNewYearsToo
Python script which automatically sends Christmas/New Year's messages from a custom messages list on Whatsapp, Facebook Messenger or via SMS in a given time range, to a custom contacts list. Time to work smart, not hard.
Stars: ✭ 81 (+350%)
Mutual labels:  sms, whatsapp
MessengerComparison
Project aimed at providing thorough comparison of Telegram, Viber and WhatsApp.
Stars: ✭ 28 (+55.56%)
Mutual labels:  viber, whatsapp
Vonage Java Sdk
Vonage Server SDK for Java. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 75 (+316.67%)
Mutual labels:  messaging, sms
Quickblox Javascript Sdk
JavaScript SDK of QuickBlox cloud backend platform
Stars: ✭ 98 (+444.44%)
Mutual labels:  messaging, whatsapp
Linebot
🤖 SDK for the LINE Messaging API for Node.js
Stars: ✭ 184 (+922.22%)
Mutual labels:  line, messaging
Whatsapp Android App
This is sample code for layout for chatting app like Whatsapp.
Stars: ✭ 32 (+77.78%)
Mutual labels:  messaging, whatsapp

Build Status codecov Packagist

CM Text SDK

A software development kit to provide ways to interact with CM.com's Text service. API used:

Requirements

  • php 7.* or 8.0 or 8.1

Usage

Instantiate the client

Using your unique ApiKey (or product token) which authorizes you on the CM platform. Always keep this key secret!

The product token can be found in the Channels application on the platform, under the Gateway section.

$client = new \CMText\TextClient('your-api-key');

Send a message

By calling SendMessage and providing message text, sender name, recipient phone number(s) and a reference (optional).

$result = $client->SendMessage('Message_Text', 'CM.com', [ 'Recipient_PhoneNumber' ], 'Your_Reference');

Get the result

SendMessage and send return an object of type TextClientResult, example:

{
  "statusMessage": "Created 1 message(s)",
  "statusCode": 201,
  "details": [
    {
      "reference": "Example_Reference",
      "status": "Accepted",
      "to": "Example_PhoneNumber",
      "parts": 1,
      "details": null
    },
    {
      "reference": "Example_Reference2",
      "status": "Rejected",
      "to": "Example_PhoneNumber2",
      "parts": 0,
      "details": "A body without content was found"
    }
  ]
}

Status codes

For all possibly returned status codes, please reference the TextClientStatusCodes class.

Sending a rich message

By using the Message class it is possible to create messages with media for channels such as WhatsApp and RCS

$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithHybridAppKey('your-secret-hybrid-app-key')
    ->WithRichMessage(
        new MediaMessage(
            'cm.com',
            'https://avatars3.githubusercontent.com/u/8234794?s=200&v=4',
            'image/png'
        )
    )
    ->WithSuggestions([
        new ReplySuggestion('Opt In', 'OK'),
        new ReplySuggestion('Opt Out', 'STOP'),
    ]);
$result = $client->send( [$message] );

Sending a WhatsApp template message

By using the Message class it is possible to create template messages. Please note that this is WhatsApp only and your template needs to be approved before sending. For more info please check our documentation: https://docs.cmtelecom.com/en/api/business-messaging-api/1.0/index#whatsapp-template-message

$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithTemplate(
            new TemplateMessage(
                new WhatsappTemplate(
                    'namespace',
                    'elementname',
                    new Language('en'),
                    [
                        new ComponentBody([
                            new ComponentParameterText('firstname')
                        ])
                    ]
                )
            )
    );
$result = $client->send( [$message] );

Sending a rich WhatsApp template message

It is also possible to send a rich template with an image!

$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithTemplate(
        new TemplateMessage(
            new WhatsappTemplate(
                'template-name',
                'the-namespace-of-template',
                new Language('en'),
                [
                    new ComponentHeader([
                        new ComponentParameterImage(
                            new MediaContent(
                                'image name',
                                'https://image.location',
                                'image/png'
                            )
                        )
                    ]),
                    new ComponentBody([
                        new ComponentParameterText('firstname')
                    ])
                ]
            )
        )
    );
$result = $client->send( [$message] );

Sending an Apple Pay Request

It is now possible to send an apple pay request only possible in Apple Business Chat

$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::IMESSAGE])
    ->WithPayment(
        new PaymentMessage(
            new ApplePayConfiguration(
                'merchant-name',
                'product-description',
                'unique-order-guid',
                1,
                'currency-code',
                'recipient-email',
                'recipient-country-code',
                'language-country-code',
                true,
                true,
                [
                    new LineItem(
                        'product-name',
                        'final-or-pending',
                        1
                    )
                ]
            )
        )
    );
$result = $client->send( [$message] );

Sending WhatsApp interactive messages

It is now possible to send list messages and reply buttons without using templates only supported in WhatsApp

$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithRichMessage(
        new WhatsAppInteractiveMessage(
            new WhatsAppInteractiveContent(
                WhatsAppInteractiveContentTypes::LIST,
                new WhatsAppInteractiveHeader(
                    WhatsAppInteractiveHeaderTypes::TEXT,
                    'List message example'
                ),
                new WhatsAppInteractiveBody('checkout our list message demo'),
                new WhatsAppInteractiveListAction(
                    'Descriptive list title',
                    [new WhatsAppInteractiveSection(
                        'Select an option',
                        [new WhatsAppInteractiveSectionRow(
                            'unique title 1',
                            rand(),
                            'description text'
                        ),new WhatsAppInteractiveSectionRow(
                            'unique title 2',
                            rand()
                        )]
                    )]
                ),
                new WhatsAppInteractiveFooter('footer text')
            )
        )
    );
$result = $client->send( [$message] );

Only with Reply buttons you can send media like image,video or document see following example.

$client = new TextClient('your-api-key');
$message = new Message('Message Text', 'Sender_name', ['Recipient_PhoneNumber']);
$message
    ->WithChannels([Channels::WHATSAPP])
    ->WithRichMessage(
        new WhatsAppInteractiveMessage(
            new WhatsAppInteractiveContent(
                WhatsAppInteractiveContentTypes::BUTTON,
                new WhatsAppInteractiveHeader(
                    WhatsAppInteractiveHeaderTypes::IMAGE,
                    null,
                    new MediaContent(
                        'media name',
                        'media.url',
                        'mime/type'
                    )
                ),
                new WhatsAppInteractiveBody('checkout our list message demo'),
                new WhatsAppInteractiveButtonAction(
                    [new WhatsAppInteractiveReplyButton(
                        'button 1 reply-text',
                        rand()
                    ),new WhatsAppInteractiveReplyButton(
                        'button 2 title',
                        rand()
                    )]
                ),
                new WhatsAppInteractiveFooter('footer text')
            )
        )
    );
$result = $client->send( [$message] );
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].