{"id":22085602,"url":"https://github.com/nexmo/vonage-php-drupal-module","last_synced_at":"2025-03-23T22:16:04.298Z","repository":{"id":62545311,"uuid":"318849570","full_name":"Nexmo/vonage-php-drupal-module","owner":"Nexmo","description":"A Drupal module that provides an interface for configuring Vonage API access and client creation","archived":false,"fork":false,"pushed_at":"2020-12-09T02:14:40.000Z","size":14,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"0.x","last_synced_at":"2025-01-29T05:24:32.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nexmo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-05T17:35:59.000Z","updated_at":"2020-12-09T02:11:57.000Z","dependencies_parsed_at":"2022-11-02T21:46:02.306Z","dependency_job_id":null,"html_url":"https://github.com/Nexmo/vonage-php-drupal-module","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Fvonage-php-drupal-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Fvonage-php-drupal-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Fvonage-php-drupal-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Fvonage-php-drupal-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nexmo","download_url":"https://codeload.github.com/Nexmo/vonage-php-drupal-module/tar.gz/refs/heads/0.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245175480,"owners_count":20572787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-01T01:15:15.096Z","updated_at":"2025-03-23T22:16:04.274Z","avatar_url":"https://github.com/Nexmo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vonage Client Module for Drupal\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n[![Apache 2.0 licensed](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](./LICENSE.txt)\n\n\u003cimg src=\"https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg\" height=\"48px\" alt=\"Nexmo is now known as Vonage\" /\u003e\n\nThis is the Vonage API PHP client module for use with the Drupal CMS.\nTo use this, you'll need a Vonage account. Sign up [for free at nexmo.com][signup].\n\n**This bundle is currently in development/beta status, so there may be bugs**\n\n * [Installation](#installation)\n * [Usage](#usage)\n * [Contributing](#contributing) \n\n## Installation\n\n### Step 1: Add the module to your composer.json\n\nOpen a command console, enter your project directory and execute the\nfollowing command to download the latest stable version of this module:\n\n```console\n$ composer require vonage/vonage_drupal\n```\n\n### Step 2: Install the Module\n\nThe module will automatically be detected by Drupal, and can be enabled by\nlogging in as a user with permissions to enable modules. Go to the \"Extend\"\npage and either search for \"Vonage\", or scroll down to the \"Communications\"\nsection. Check the box next to \"Vonage API SDK\", and click the \"Install\"\nbutton.\n\n### Step 3: Configuration\n\nYou can configure the bundle with your application details by goint to the \n\"Configuration\" page and click on \"Vonage API Settings\" under the \"System\"\nsection.\n\nYou can then fill in the needed credentials from your [Vonage Dashboard][dashboard].\nThe module allows you to enter your Vonage API key and secret, and if you are\nusing Application-based APIs like the Voice API you can enter an Application ID\nas well as a private key to use.\n\nOnce you have entered either set of credentials, you can test basic\nfunctionlity using the \"Vonage SMS API Testing\" or \"Vonage Voice API Testing\"\ntabs. These allow you to send a test SMS and test voice call.\n\nAfter you have entered your credentials, you can use any of the APIs that\nare available in our PHP SDK. \n\n## Usage\n\n### Calling the Vonage APIs\n\nThis bundle takes care of all the client creation needed for making the Vonage\nclient, and adds it to the service container. You can pull the class from the\nservice container or use it as a service in other service declarations.\n\n```php\nnamespace Drupal\\my_module\\Controller;\n\nuse Vonage\\Client;\nuse Vonage\\SMS\\Message\\SMS;\nuse Drupal\\Core\\Controller\\ControllerBase;\nuse Symfony\\Component\\DependencyInjection\\ContainerInterface;\n\nclass MyController extends ControllerBase\n{\n    /**\n     * @var Client\n     */\n    protected $client;\n\n    public function __construct($client)\n    {\n        $this-\u003eclient = $client;\n    }\n\n    public static function create(ContainerInterface $container)\n    {\n        return new static($container-\u003eget(Client::class));\n    }\n\n    public function controllerAction(): array\n    {\n        $this-\u003eclient-\u003esms()-\u003esend(\n            new SMS($to, from, $message)\n        );\n\n        $build = [\n            '#markup' =\u003e 'Hello World!',\n        ];\n\n        return $build;\n    }\n}\n```\n\n### Working with Incoming Webhooks\n\nMany of the Vonage APIs, especially the SMS and Voice API, work with your\napplication through a concept of a Webhook. This is where the Vonage API\nservers make a request to YOUR application, instead of your application\nmaking a request to Vonage.\n\nThe Vonage API provides a way to interpret the incoming web request, and will\ngenerate an appropriate object. All you need to do is know which kind of\nrequest, either SMS or Voice, is coming to a specific route.\n\n#### Incoming SMS Messages\n\nWhen you elect to have a number accept SMS, Vonage will ask for the URL to send\nthe information to. You can create a controller in your module with a route\nthat can accept the incoming request, and use the `\\Vonage\\SMS\\Webhook\\Factory`\nto convert that request into an object.\n\n```php\nnamespace Drupal\\my_module\\Controller;\n\nuse Vonage\\SMS\\Webhook\\Factory;\nuse Vonage\\SMS\\Webhook\\InboundSMS;\nuse Drupal\\Core\\Controller\\ControllerBase;\n\nclass MyController extends ControllerBase\n{\n    public function incomingSMS(): array\n    {\n        /** @var InboundSMS $inboundSMS */\n        $inboundSMS = Factory::createFromGlobals();\n\n        $to = $inboundSMS-\u003egetTo();\n        $from = $inboundSMS-\u003egetFrom();\n        $text = $inboundSMS-\u003egetText();\n\n        // ...\n    }\n}\n```\n\n#### Incoming Voice Calls\n\nIf you are building an interactive voice application, you can set up an Answer\nWebhook in the Application Settings on the Vonage Dashboard. You can create a\ncontroller in your module with a route that can accept the incoming call and\nuse the `\\Vonage\\Voice\\Webhook\\Factory` to convert that request into an object.\n\n```php\nnamespace Drupal\\my_module\\Controller;\n\nuse Vonage\\Voice\\Webhook\\Factory;\nuse Vonage\\Voice\\Webhook\\Answer;\nuse Drupal\\Core\\Controller\\ControllerBase;\n\nclass MyController extends ControllerBase\n{\n    public function answerCall(): array\n    {\n        /** @var Answer $inboundCall */\n        $inboundCall = Factory::createFromGlobals();\n\n        $to = $inboundCall-\u003egetTo();\n        $from = $inboundCall-\u003egetFrom();\n        $uuid = $inboundCall-\u003egetUuid();\n\n        // ...\n    }\n}\n```\n\n#### Incoming Voice Events\n\nIn addition to being able to answer a call, the Voice API is heavily event\ndriven. You can set up an Event Webhook in the Application Settings on the\nVonage Dashboard in addition to the Answer webhook. You can create a\ncontroller in your module with a route that can accept the events and use the\n`\\Vonage\\Voice\\Webhook\\Factory` to convert that request into an object.\n\nWhen working with the objects, you will want to inspect the type of object\nthat is generated as there are many types of events with their own object\nstructure.\n\nYou can see all the available event types at [https://github.com/Vonage/vonage-php-sdk-core/tree/master/src/Voice/Webhook](https://github.com/Vonage/vonage-php-sdk-core/tree/master/src/Voice/Webhook).\n\n```php\nnamespace Drupal\\my_module\\Controller;\n\nuse Vonage\\Voice\\Webhook\\Factory;\nuse Vonage\\Voice\\Webhook\\Answer;\nuse Vonage\\Voice\\Webhook\\Event;\nuse Drupal\\Core\\Controller\\ControllerBase;\n\nclass MyController extends ControllerBase\n{\n    public function voiceEventHandler(): array\n    {\n        $event = Factory::createFromGlobals();\n\n        if ($event instanceof Event) {\n            // ...\n        } elseif ($event instanceof Notification) {\n            // ...\n        }\n\n        // ...\n    }\n}\n```\n\n## Contributing\n\nThis library is actively developed, and we love to hear from you! Please feel free to [create an issue][issues] or [open a pull request][pulls] with your questions, comments, suggestions and feedback.\n\n[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL\u0026utm_medium=github\u0026utm_campaign=php-drupal-module\n[issues]: https://github.com/nexmo/vonage-php-drupal-module/issues\n[pulls]: https://github.com/nexmo/vonage-php-drupal-module/pulls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexmo%2Fvonage-php-drupal-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnexmo%2Fvonage-php-drupal-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexmo%2Fvonage-php-drupal-module/lists"}