Skip to content

Commit 32e99bf

Browse files
committed
Swapped to Vonage namespace
1 parent 14d5601 commit 32e99bf

File tree

87 files changed

+279
-279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+279
-279
lines changed

.env-example

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
NEXMO_API_KEY=
2-
NEXMO_API_SECRET=
3-
NEXMO_APPLICATION_ID=
4-
NEXMO_APPLICATION_PRIVATE_KEY_PATH=
1+
VONAGE_API_KEY=
2+
VONAGE_API_SECRET=
3+
VONAGE_APPLICATION_ID=
4+
VONAGE_APPLICATION_PRIVATE_KEY_PATH=
55
FROM=
6-
NEXMO_TO_NUMBER=
6+
VONAGE_TO_NUMBER=
77
RECIPIENT_NUMBER=
88
TO_NUMBER=
9-
NEXMO_SECRET_ID=
9+
VONAGE_SECRET_ID=
1010
INSIGHT_NUMBER=
1111
SMS_CALLBACK_URL=
1212

1313
# Numbers API examples
14-
NEXMO_NUMBER=447700900001
15-
NEXMO_NUMBER_TYPE=mobile-lvn
16-
NEXMO_NUMBER_FEATURES=VOICE,SMS
14+
VONAGE_NUMBER=447700900001
15+
VONAGE_NUMBER_TYPE=mobile-lvn
16+
VONAGE_NUMBER_FEATURES=VOICE,SMS
1717
COUNTRY_CODE=GB
1818
NUMBER_SEARCH_PATTERN=1
1919
NUMBER_SEARCH_CRITERIA=234

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Nexmo APIs Quickstart Examples for PHP
1+
# Vonage APIs Quickstart Examples for PHP
22

33
<img src="https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg" height="48px" alt="Nexmo is now known as Vonage" />
44

@@ -8,21 +8,21 @@ Quickstarts also available for [Java](https://github.com/nexmo/nexmo-java-code-s
88

99
## Setup
1010

11-
These code samples are meant to be used for [https://developer.nexmo.com/](https://developer.nexmo.com/), and are structured in such a way as to be used for internal testing. Developers are free to use these code snippets as a reference, but these may require changes to be worked into your specific application. We recommend checking out the [Nexmo Developer Website](https://developer.nexmo.com/), which displays these code snippets in a more copy/paste fashion.
11+
These code samples are meant to be used for [https://developer.nexmo.com/](https://developer.nexmo.com/), and are structured in such a way as to be used for internal testing. Developers are free to use these code snippets as a reference, but these may require changes to be worked into your specific application. We recommend checking out the [Vonage Developer Website](https://developer.nexmo.com/), which displays these code snippets in a more copy/paste fashion.
1212

1313
If you would like to run these examples yourself, you will need to do the following:
1414

1515
1. Run `composer install` in the root of the repository
1616
2. Copy `.env-example` to `.env`
17-
3. Edit `.env` with your Nexmo credentials
17+
3. Edit `.env` with your Vonage credentials
1818

1919
From there, you can fill out the various environment variables as detailed by the individual code snippet. Some snippets may share common environment variables.
2020

2121
Larger or more complex snippets may include their own `composer.json` file and have additional requirements. Please check any READMEs inside of the larger examples for setup instructions.
2222

23-
## Configure with Your Nexmo API Keys
23+
## Configure with Your Vonage API Keys
2424

25-
To use this sample you will first need a [Nexmo account](https://dashboard.nexmo.com/sign-up). Once you have your own API credentials, rename
25+
To use this sample you will first need a [Vonage account](https://dashboard.nexmo.com/sign-up). Once you have your own API credentials, rename
2626
the `.env-example` file to `.env` and set the values as required.
2727

2828
For some of the examples, you will need to [buy a number](https://dashboard.nexmo.com/buy-numbers).

account/account-balance.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$response = $client->account()->getBalance();
99
echo round($response->getBalance(), 2) . " EUR\n";

account/configure-account.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$response = $client->account()->updateConfig([
99
"sms_callback_url" => SMS_CALLBACK_URL

applications/create-application.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
require_once __DIR__ . '/../config.php';
44
require_once __DIR__ . '/../vendor/autoload.php';
55

6-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
7-
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic));
6+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
7+
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));
88

99
try {
1010
$application = new Nexmo\Application\Application();

applications/delete-application.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
require_once __DIR__ . '/../config.php';
44
require_once __DIR__ . '/../vendor/autoload.php';
55

6-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
7-
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic));
6+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
7+
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));
88

99
try {
1010
$isDeleted = $client->applications()->delete(MESSAGES_APPLICATION_ID);
@@ -14,8 +14,8 @@
1414
} else {
1515
echo "Could not delete application " . MESSAGES_APPLICATION_ID . PHP_EOL;
1616
}
17-
} catch (\Nexmo\Client\Exception\Request $e) {
17+
} catch (\Vonage\Client\Exception\Request $e) {
1818
echo "There was a problem with the request: " . $e->getMessage() . PHP_EOL;
19-
} catch (\Nexmo\Client\Exception\Server $e) {
19+
} catch (\Vonage\Client\Exception\Server $e) {
2020
echo "The server encounted an error: " . $e->getMessage() . PHP_EOL;
2121
}

applications/get-application.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
require_once __DIR__ . '/../config.php';
44
require_once __DIR__ . '/../vendor/autoload.php';
55

6-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
7-
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic));
6+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
7+
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));
88

99
try {
1010
$application = $client->applications()->get(MESSAGES_APPLICATION_ID);
1111

1212
echo $application->getId() . PHP_EOL;
1313
echo $application->getName() . PHP_EOL;
14-
} catch (\Nexmo\Client\Exception\Request $e) {
14+
} catch (\Vonage\Client\Exception\Request $e) {
1515
echo "There was a problem with the request: " . $e->getMessage() . PHP_EOL;
16-
} catch (\Nexmo\Client\Exception\Server $e) {
16+
} catch (\Vonage\Client\Exception\Server $e) {
1717
echo "The server encounted an error: " . $e->getMessage() . PHP_EOL;
1818
}

applications/list-applications.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
require_once __DIR__ . '/../config.php';
44
require_once __DIR__ . '/../vendor/autoload.php';
55

6-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
7-
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic));
6+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
7+
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));
88

99
foreach ($client->applications() as $application) {
1010
echo sprintf("%s: %s\n", $application->getId(), $application->getName());

applications/update-application.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
require_once __DIR__ . '/../config.php';
44
require_once __DIR__ . '/../vendor/autoload.php';
55

6-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
7-
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic));
6+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
7+
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));
88

99
try {
1010
$application = $client->applications()->get(MESSAGES_APPLICATION_ID);

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"nexmo/client": "^2.0",
3+
"vonage/client": "^2.0",
44
"vlucas/phpdotenv": "^2.5"
55
}
66
}

initialize/application.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
$keypair = new \Nexmo\Client\Credentials\Keypair(
4-
file_get_contents(NEXMO_APPLICATION_PRIVATE_KEY_PATH),
5-
NEXMO_APPLICATION_ID
3+
$keypair = new \Vonage\Client\Credentials\Keypair(
4+
file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH),
5+
VONAGE_APPLICATION_ID
66
);
77

8-
$client = new \Nexmo\Client($keypair);
8+
$client = new \Vonage\Client($keypair);

initialize/basic.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

3-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
4-
$client = new \Nexmo\Client($basic);
3+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
4+
$client = new \Vonage\Client($basic);

initialize/full.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
3+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
44

5-
$keypair = new \Nexmo\Client\Credentials\Keypair(
6-
file_get_contents(NEXMO_APPLICATION_PRIVATE_KEY_PATH),
7-
NEXMO_APPLICATION_ID
5+
$keypair = new \Vonage\Client\Credentials\Keypair(
6+
file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH),
7+
VONAGE_APPLICATION_ID
88
);
99

10-
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic, $keypair));
10+
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic, $keypair));

number-insights/advanced-async-trigger.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$options = getopt('n:c:h');
99

@@ -45,10 +45,10 @@
4545
try {
4646
$client->insights()->advancedAsync(SEARCH_NUMBER, CALLBACK_WEBHOOK);
4747
echo "The number will be looked up soon.";
48-
} catch (\Nexmo\Client\Exception\Request $e) {
48+
} catch (\Vonage\Client\Exception\Request $e) {
4949
error_log("Client error: " . $e->getMessage());
5050
exit(1);
51-
} catch (\Nexmo\Client\Exception\Server $e) {
51+
} catch (\Vonage\Client\Exception\Server $e) {
5252
error_log("Server error: " . $e->getMessage());
5353
exit(1);
5454
}

number-insights/advanced-cnam.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$insights = $client->insights()->advancedCnam(INSIGHT_NUMBER);
99

number-insights/advanced.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$insights = $client->insights()->advanced(INSIGHT_NUMBER);
99

number-insights/basic.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$insights = $client->insights()->basic(INSIGHT_NUMBER);
99

number-insights/standard-cnam.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$insights = $client->insights()->standardCnam(INSIGHT_NUMBER);
99

number-insights/standard.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$insights = $client->insights()->standard(INSIGHT_NUMBER);
99

numbers/cancel.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
try {
9-
$client->numbers()->cancel(NEXMO_NUMBER);
9+
$client->numbers()->cancel(VONAGE_NUMBER);
1010
echo "Number cancelled";
1111
}
1212

numbers/list-owned.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
require_once __DIR__ . '/../config.php';
44
require_once __DIR__ . '/../vendor/autoload.php';
55

6-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
7-
$client = new \Nexmo\Client($basic);
6+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
7+
$client = new \Vonage\Client($basic);
88

99
try {
10-
$filter = new \Nexmo\Numbers\Filter\OwnedNumbers();
10+
$filter = new \Vonage\Numbers\Filter\OwnedNumbers();
1111
$filter
1212
->setPattern((int) NUMBER_SEARCH_CRITERIA)
1313
->setSearchPattern((int) NUMBER_SEARCH_PATTERN)

numbers/purchase.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
try {
9-
$client->numbers()->purchase(NEXMO_NUMBER, COUNTRY_CODE);
9+
$client->numbers()->purchase(VONAGE_NUMBER, COUNTRY_CODE);
1010
echo "Number purchased";
1111
} catch (Exception $e) {
1212
echo "Error purchasing number";

numbers/search-available.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?php
22

3-
use Nexmo\Numbers\Filter\AvailableNumbers;
4-
use Nexmo\Entity\IterableAPICollection;
3+
use Vonage\Numbers\Filter\AvailableNumbers;
4+
use Vonage\Entity\IterableAPICollection;
55
require_once __DIR__ . '/../config.php';
66
require_once __DIR__ . '/../vendor/autoload.php';
77

8-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
9-
$client = new \Nexmo\Client($basic);
8+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
9+
$client = new \Vonage\Client($basic);
1010

1111
/** @var IterableAPICollection $response */
1212
$filter = new AvailableNumbers([
1313
"pattern" => (int) NUMBER_SEARCH_CRITERIA,
1414
"search_pattern" => (int) NUMBER_SEARCH_PATTERN,
15-
"type" => NEXMO_NUMBER_TYPE,
16-
"features" => NEXMO_NUMBER_FEATURES,
15+
"type" => VONAGE_NUMBER_TYPE,
16+
"features" => VONAGE_NUMBER_FEATURES,
1717
]);
1818
$response = $client->numbers()->searchAvailable(COUNTRY_CODE, $filter);
1919

numbers/update.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
require_once __DIR__ . '/../config.php';
44
require_once __DIR__ . '/../vendor/autoload.php';
55

6-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
7-
$client = new \Nexmo\Client($basic);
6+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
7+
$client = new \Vonage\Client($basic);
88

99
try {
10-
$number = $client->numbers()->get(NEXMO_NUMBER);
11-
$number->setAppId(NEXMO_APPLICATION_ID);
10+
$number = $client->numbers()->get(VONAGE_NUMBER);
11+
$number->setAppId(VONAGE_APPLICATION_ID);
1212
$client->numbers()->update($number);
1313
echo "Number updated" . PHP_EOL;
1414

redact/transaction.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
// This request returns a 204 on success, and throws on error
9-
$client->redact()->transaction(NEXMO_REDACT_ID, NEXMO_REDACT_TYPE);
9+
$client->redact()->transaction(VONAGE_REDACT_ID, VONAGE_REDACT_TYPE);

secret-management/create-a-secret.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
require_once __DIR__ . '/../config.php';
33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
6-
$client = new \Nexmo\Client($basic);
5+
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
6+
$client = new \Vonage\Client($basic);
77

88
$secret = 'awes0meNewSekret!!;';
99

10-
$client->account()->createSecret(NEXMO_API_KEY, $secret);
10+
$client->account()->createSecret(VONAGE_API_KEY, $secret);
1111

0 commit comments

Comments
 (0)