Code Monkey home page Code Monkey logo

messente-api-php's Introduction

Messente API Library

  • Messente API version: 2.0.0
  • PHP artifact version: 3.0.0

Messente is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds tools to help organizations connect their services to people anywhere in the world.

Installation

Install Messente API library with composer require messente/messente-api-php.

Features

Messente API has the following features:

Messente API Library provides the operations described below to access the features.

BlacklistApi

  1. Adds a phone number to the blacklist addToBlacklist
  2. Deletes a phone number from the blacklist deleteFromBlacklist
  3. Returns all blacklisted phone numbers fetchBlacklist
  4. Checks if a phone number is blacklisted isBlacklisted

BulkMessagingApi

  1. Sends a bulk Omnimessage sendBulkOmnimessage

ContactsApi

  1. Adds a contact to a group addContactToGroup
  2. Creates a new contact createContact
  3. Deletes a contact deleteContact
  4. Lists a contact fetchContact
  5. Lists groups of a contact fetchContactGroups
  6. Returns all contacts fetchContacts
  7. Removes a contact from a group removeContactFromGroup
  8. Updates a contact updateContact

DeliveryReportApi

  1. Retrieves the delivery report for the Omnimessage retrieveDeliveryReport

GroupsApi

  1. Creates a new group with the provided name createGroup
  2. Deletes a group deleteGroup
  3. Lists a group fetchGroup
  4. Returns all groups fetchGroups
  5. Updates a group with the provided name updateGroup

NumberLookupApi

  1. Requests info about phone numbers fetchInfo

OmnimessageApi

  1. Cancels a scheduled Omnimessage cancelScheduledMessage
  2. Sends an Omnimessage sendOmnimessage

StatisticsApi

  1. Requests statistics reports for each country createStatisticsReport

Auth

Type: HTTP basic authentication

Read the external getting-started article which explains API keys and Sender ID logic.

Getting started: sending an omnimessage

<?php
require_once(__DIR__ . '/../vendor/autoload.php');

use Messente\Api\Api\OmnimessageApi;
use Messente\Api\Model\Omnimessage;
use Messente\Api\Configuration;
use Messente\Api\Model\WhatsApp;
use Messente\Api\Model\WhatsAppParameter;
use Messente\Api\Model\WhatsAppComponent;
use Messente\Api\Model\WhatsAppLanguage;
use Messente\Api\Model\WhatsAppTemplate;


// Configure HTTP basic authorization: basicAuth
$config = Configuration::getDefaultConfiguration()
    ->setUsername('<MESSENTE_API_USERNAME>')
    ->setPassword('<MESSENTE_API_PASSWORD>');

$apiInstance = new OmnimessageApi(
    new \GuzzleHttp\Client(),
    $config
);

$omnimessage = new Omnimessage([
    "to" => "<phone number in e.164 format>"
]);

$viber = new Viber(
    ["text" => "Hello Viber!", "sender" => "MyViberSender"]
);

$sms = new SMS(
    ["text" => "Hello SMS!", "sender" => "MySmsSender"]
);

$whatsAppParameters = [new WhatsAppParameter(['type' => 'text', 'text' => 'hello whatsapp'])];
$whatsAppComponent = new WhatsAppComponent(['type' => 'body', 'parameters' => $whatsAppParameters]);
$whatsAppLanguage = new WhatsAppLanguage(['code' => '<language_code>']);
$whatsAppTemplate = new WhatsAppTemplate(
    [
        'name'=> '<template_name>',
        'language'=> $whatsAppLanguage,
        'components' => [$whatsAppComponent]
    ]
);

$whatsapp = new WhatsApp(
    [
        'sender' => '<sender name (optional)>',
        'template' => $whatsAppTemplate,
    ]
);

$omnimessage->setMessages([$whatsapp, $viber, $sms]);


try {
    $result = $apiInstance->sendOmnimessage($omnimessage);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling sendOmnimessage: ', $e->getMessage(), PHP_EOL;
}
?>

License

Apache-2.0

Terms

https://messente.com/terms-and-conditions

messente-api-php's People

Contributors

api-librarian avatar glintik avatar jbaanus avatar krystian-wojakiewicz avatar realerikrani avatar ukuloskit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

messente-api-php's Issues

Rebuild package using a newer OpenAPI Generator

OpenAPI Generator 6.0.0, released last year, included fixes to generate PHP 8.1 compatible files.

[08-Jun-2023 10:25:20 UTC] PHP Deprecated:  Return type of Messente\Api\Model\ErrorItemStatistics::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/messente/messente-api-php/lib/Model/ErrorItemStatistics.php on line 350
[08-Jun-2023 10:25:20 UTC] PHP Deprecated:  Return type of Messente\Api\Model\ErrorItemStatistics::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/messente/messente-api-php/lib/Model/ErrorItemStatistics.php on line 362

Composer: Your requirements could not be resolved to an installable set of packages

Error

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires messente/messente-api-php ^2.0 -> satisfiable by messente/messente-api-php[2.0.0].
    - messente/messente-api-php 2.0.0 requires guzzlehttp/psr7 ^1.8 -> found guzzlehttp/psr7[1.8.0, ..., 1.x-dev] but the package is fixed to 2.4.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require messente/messente-api-php:*" to figure out if any version is installable, or "composer require messente/messente-api-php:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Step to reproduce the error

composer global require laravel/installer

laravel new example-app

cd example-app

composer require messente/messente-api-php

System
OS: Windows 10
PHP version: 8.2.0
Composer: 2.4.4

The error is similar to #13

Through error on 8.x

  • Root composer.json requires messente/messente-api-php ^1.4 -> satisfiable by messente/messente-api-php[1.4.0].
  • messente/messente-api-php 1.4.0 requires guzzlehttp/guzzle ^6.2 -> found guzzlehttp/guzzle[6.2.0, ..., 6.5.x-dev] but it conflicts with your root composer.json require (^7.0.1).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.