Download the PHP package nexmo/client-core without Composer

On this page you can find all versions of the php package nexmo/client-core. 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?
nexmo/client-core
Rate from 1 - 5
Rated 4.00 based on 2 reviews

Informations about the package client-core

Client Library for PHP

Build Status Latest Stable Version codecov

Nexmo is now known as Vonage

Support Notice

This library and it's associated packages, nexmo/client and nexmo/client-core have transitioned into a "Maintenance Only" mode. For the next twelve (12) months, this library will only receive bug or security fixes. This library will officially be End of Life as of October 1st, 2021.

We recommend users begin migrating over to https://github.com/vonage/vonage-php-sdk-core and the vonage/client and vonage/client-core packages for their applications. The Vonage packages fully support the \Nexmo namespace and should be a drop-in replacement for the Nexmo packages.

If you have any questions, feel free to reach out to us at [email protected] or through our Community Slack at https://developer.nexmo.com/community/slack


This library requires a minimum PHP version of 7.2

This is the PHP client library for use Vonage's API. To use this, you'll need a Vonage account. Sign up for free at nexmo.com.

Migration

This package has officially moved to a "maintenance only" mode, and we highly suggest moving to vonage/client and vonage/client-core for all codebases. While we will be supporting this package with any needed bug or security fixes, no new features will be developed for this codebase, including new product releases. We are providing up to twelve (12) months of support to give users time to upgrade.

We have tried to make the upgrade as seamless as possible for all users.

Step 1 - Find out Current Versions

What we need:

The first thing we need to do is figure out what, and which versions, you have installed. The quickest way is to just open up composer.json and search for "nexmo/client" and "nexmo/client-core", and see which one you have. You should have either nexmo/client or nexmo/client-core requested in composer.json. Take note of which is in your composer.json file.

To find out what version of nexmo/client-core you have installed, you can run:

This should give you the following output, of which we care about the "versions" line:

Take note of that version, as it will determine your next steps.

Step 2 - Change the Packages

I have nexmo/client in composer.json

Updating the new packages is fairly painless in most cases. We need to remove the nexmo/client package and replace it with the vonage/client package. This can be done using Composer, as it will handle modifying your composer.json and composer.lock files for you.

Depending on the version of nexmo/client-core you have installed, you may need to do additional upgrade work. The new packages are designed to continue to work with the \Nexmo namespace, so all your existing code should continue to work. You can schedule a refactor at your leisure.

I have nexmo/client-core in composer.json

Updating the new packages is fairly painless in most cases. We need to remove the nexmo/client-core package and replace it with the vonage/client-core package. This can be done using Composer, as it will handle modifying your composer.json and composer.lock files for you.

Depending on the version of nexmo/client-core you have installed, you may need to do additional upgrade work. The new packages are designed to continue to work with the \Nexmo namespace, so all your existing code should continue to work. You can schedule a refactor at your leisure.

We continue to support PSR-18 and HTTPlug-compatible HTTP clients, and if you are using a custom client these should continue to work.

Installation

To use the client library you'll need to have created a Vonage account.

To install the PHP client library to your project, we recommend using Composer.

You don't need to clone this repository to use this library in your own projects. Use Composer to install it from Packagist.

If you're new to Composer, here are some resources that you may find useful:

Usage

If you're using Composer, make sure the autoloader is included in your project's bootstrap file:

Create a client with your API key and secret:

For testing purposes you may want to change the URL that vonage/client makes requests to from api.nexmo.com to something else. You can do this by providing an array containing base_api_url as the second parameter when creating a Vonage\Client instance.

For APIs that would usually hit rest.nexmo.com, supplying a base_rest_url as an option to the constructor will change those requests.

Examples

Sending a Message

To use Vonage's SMS API to send an SMS message, call the $client->sms()->send() method.

A message object is used to create the SMS messages. Each message type can be constructed with the required parameters, and a fluent interface provides access to optional parameters.

The message object is passed to the send method:

Once sent, the message object can be used to access the response data.

Since each SMS message can be split into multiple messages, the response contains an object for each message that was generated. You can check to see how many messages were generated using the standard count() function in PHP. If you want to get the first message, you can use the current() method on the response.

The send example also has full working examples.

Receiving a Message

Inbound messages are sent to your application as a webhook, and the client library provides a way to create an inbound message object from a webhook:

Signing a Message

You may also like to read the documentation about message signing.

The SMS API supports the ability to sign messages by generating and adding a signature using a "Signature Secret" rather than your API secret. The algorithms supported are:

Both your application and Vonage need to agree on which algorithm is used. In the dashboard, visit your account settings page and under "API Settings" you can select the algorithm to use. This is also the location where you will find your "Signature Secret" (it's different from the API secret).

Create a client using these credentials, and the algorithm to use, for example:

Using this client, your SMS API messages will be sent as signed messages.

Verifying an Incoming Message Signature

You may also like to read the documentation about message signing.

If you have message signing enabled for incoming messages, the SMS webhook will include the fields sig, nonce and timestamp. To verify the signature is from Vonage, you create a Signature object using the incoming data, your signature secret and the signature method. Then use the check() method with the actual signature that was received (usually _GET['sig']) to make sure, that it is correct.

Using your signature secret and the other supplied parameters, the signature can be calculated and checked against the incoming signature value.

Starting a Verification

Vonage's Verify API makes it easy to prove that a user has provided their own phone number during signup, or implement second factor authentication during sign in.

You can start a verification process using code like this:

Once the user inputs the pin code they received, call the /check endpoint with the request ID and the pin to confirm the pin is correct.

Controlling a Verification

To cancel an in-progress verification, or to trigger the next attempt to send the confirmation code, you can pass either an existing verification object to the client library, or simply use a request ID:

Checking a Verification

In the same way, checking a verification requires the code the user provided, and the request ID:

Searching For a Verification

You can check the status of a verification, or access the results of past verifications using a request ID. The verification object will then provide a rich interface:

Payment Verification

Vonage's Verify API has SCA (Secure Customer Authentication) support, required by the PSD2 (Payment Services Directive) and used by applications that need to get confirmation from customers for payments. It includes the payee and the amount in the message.

Start the verification for a payment like this:

Once the user inputs the pin code they received, call the /check endpoint with the request ID and the pin to confirm the pin is correct.

Making a Call

All $client->voice() methods require the client to be constructed with a Vonage\Client\Credentials\Keypair, or a Vonage\Client\Credentials\Container that includes the Keypair credentials:

You can start a call using an OutboundCall object:

Building a call with NCCO Actions

Full parameter lists for NCCO Actions can be found in the Voice API Docs.

Each of these examples uses the following structure to add actions to a call:

Record a call

Your webhook url will receive a payload like this:

You can then fetch and store the recording like this:

Send a text to voice call

Stream an audio file on a call

Collect user input from a call

Supports keypad entry as well as voice. NB. the input action must follow an action with bargeIn set to true

The webhook URL will receive a payload containing the input from the user with relative confidence ratings for speech input.

Send a notification to a webhook url

The webhook URL will receive a payload as specified in the request.

Fetching a Call

You can fetch a call using a Vonage\Call\Call object, or the call's UUID as a string:

You can also search for calls using a Filter.

Creating an Application

Application are configuration containers. You can create one using a simple array structure:

You can also pass the client an application object:

Fetching Applications

You can iterate over all your applications:

Or you can fetch an application using a string UUID, or an application object.

Updating an Application

Once you have an application object, you can modify and save it.

List Your Numbers

You can list the numbers owned by your account and optionally include filtering:

search_pattern:

has_application:

application_id:

Search Available Numbers

You can search for numbers available to purchase in a specific country:

By default, this will only return the first 10 results. You can add an additional \Vonage\Numbers\Filter\AvailableNumbers filter to narrow down your search.

Purchase a Number

To purchase a number, you can pass in a value returned from number search:

Or you can specify the number and country manually:

Update a Number

To update a number, use numbers()->update and pass in the configuration options you want to change. To clear a setting, pass in an empty value.

Cancel a Number

To cancel a number, provide the msisdn:

Managing Secrets

An API is provided to allow you to rotate your API secrets. You can create a new secret (up to a maximum of two secrets) and delete the existing one once all applications have been updated.

To get a list of the secrets:

You can create a new secret (the created dates will help you know which is which):

And delete the old secret (any application still using these credentials will stop working):

Pricing

Prefix Pricing

If you know the prefix of a country you want to call, you can use the prefix-pricing endpoint to find out costs to call that number. Each prefix can return multiple countries (e.g. 1 returns US, CA and UM):

Check your Balance

Check how much credit remains on your account:

View and Change Account Configuration

Inspect the current settings on the account:

Update the default callback URLs for incoming SMS messages and delivery receipts:

Get Information About a Number

The Number Insights API allows a user to check that a number is valid and to find out more about how to use it.

Basic and Standard Usage

You can use either the basic() or standard() methods (an advanced() method is available, but it is recommended to use the async option to get advanced info), like this:

The data is returned in the $insights variable in the example above.

Advanced Usage

To get advanced insights, use the async feature and supply a URL for the webhook to be sent to:

Check out the documentation for what to expect in the incoming webhook containing the data you requested.

Supported APIs

API API Release Status Supported?
Account API General Availability
Alerts API General Availability
Application API General Availability
Audit API Beta
Conversation API Beta
Dispatch API Beta
External Accounts API Beta
Media API Beta
Messages API Beta
Number Insight API General Availability
Number Management API General Availability
Pricing API General Availability
Redact API General Availability
Reports API Beta
SMS API General Availability
Verify API General Availability
Voice API General Availability

Troubleshooting

Checking for Deprecated Features

Over time, the Vonage APIs evolve and add new features, change how existing features work, and deprecate and remove older methods and features. To help developers know when deprecation changes are being made, the SDK will trigger an E_USER_DEPRECATION warning. These warnings will not stop the execution of code, but can be an annoyance in production environments.

To help with this, by default these notices are suppressed. In development, you can enable these warnings by passing an additional configuration option to the \Vonage\Client constructor, called show_deprecations. Enabling this option will show all deprecation notices.

If you notice an excessive amount of deprecation notices in production environments, make sure the configuration option is absent, or at least set to false.

unable to get local issuer certificate

Some users have issues making requests due to the following error:

This is due to some PHP installations not shipping with a list of trusted CA certificates. This is a system configuration problem, and not specific to either cURL or Vonage.

IMPORTANT: In the next paragraph we provide a link to a CA certificate bundle. Vonage do not guarantee the safety of this bundle, and you should review it yourself before installing any CA bundle on your machine.

To resolve this issue, download a list of trusted CA certificates (e.g. the curl bundle) and copy it on to your machine. Once this is done, edit php.ini and set the curl.cainfo parameter:

Pass custom HTTP client

We allow use of any HTTPlug adapter or PSR-18 compatible HTTP client, so you can create a client with alternative configuration if you need it, for example to take account of a local proxy, or deal with something else specific to your setup.

Here's an example that reduces the default timeout to 5 seconds to avoid long delays if you have no route to our servers:

Accessing Response Data

When things go wrong, you'll receive an Exception. The Vonage exception classes Vonage\Client\Exception\Request and Vonage\Client\Exception\Server support an additional getEntity() method which you can use in addition to getCode() and getMessage() to find out more about what went wrong. The entity returned will typically be an object related to the operation, or the response object from the API call.

Composer installation fails due to Guzzle Adapter

If you have a conflicting package installation that cannot co-exist with our recommended guzzlehttp/guzzle package, then you may install the package vonage/client-core along with any package satisfying the php-http/client-implementation requirement.

See the Packagist page for client-implementation for options.

Enabling Request/Response Logging

Our client library has support for logging the request and response for debugging via PSR-3 compatible logging mechanisms. If the debug option is passed into the client and a PSR-3 compatible logger is set in our client's service factory, we will use the logger for debugging purposes.

ENABLING DEBUGING LOGGING HAS THE POTENTIAL FOR LOGGING SENSITIVE INFORMATION, DO NOT ENABLE IN PRODUCTION

Contributing

This library is actively developed, and we love to hear from you! Please feel free to create an issue or open a pull request with your questions, comments, suggestions and feedback.


All versions of client-core with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-json Version *
ext-mbstring Version *
laminas/laminas-diactoros Version ^2.4
lcobucci/jwt Version ^3.4|^4.0
composer/package-versions-deprecated Version ^1.11
psr/container Version ^1.0
psr/http-client-implementation Version ^1.0
vonage/nexmo-bridge Version ^0.1.0
psr/log Version ^1.1
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 nexmo/client-core contains the following files

Loading the files please wait ....