Skip to content

change verify snippets to new variables #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions network-apis/number-verification/verify-phone-number.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require_once __DIR__ . '../../config.php';
require_once __DIR__ . '../../vendor/autoload.php';

$credentials = new \Vonage\Client\Credentials\Gnp(
VONAGE_PHONE_NUMBER,
file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH),
VONAGE_APPLICATION_ID
);

$client = new \Vonage\Client($credentials);

$result = $client->numberVerification()->verifyNumber(PHONE_NUMBER);
14 changes: 14 additions & 0 deletions network-apis/sim-swap/check-sim-swap-date.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require_once __DIR__ . '../../config.php';
require_once __DIR__ . '../../vendor/autoload.php';

$credentials = new \Vonage\Client\Credentials\Gnp(
VONAGE_PHONE_NUMBER,
file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH),
VONAGE_APPLICATION_ID
);

$client = new \Vonage\Client($credentials);

$result = $client->simswap()->checkSimSwapDate(PHONE_NUMBER);
14 changes: 14 additions & 0 deletions network-apis/sim-swap/check-sim-swap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require_once __DIR__ . '../../config.php';
require_once __DIR__ . '../../vendor/autoload.php';

$credentials = new \Vonage\Client\Credentials\Gnp(
VONAGE_PHONE_NUMBER,
file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH),
VONAGE_APPLICATION_ID
);

$client = new \Vonage\Client($credentials);

$result = $client->simswap()->checkSimSwap(PHONE_NUMBER);
8 changes: 4 additions & 4 deletions verify/cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
require_once __DIR__ . '/../vendor/autoload.php';

// Support direct execution from command line or via a GET request as a web server
if (!defined('REQUEST_ID')) {
define('REQUEST_ID', isset($argv[1])? $argv[1]: $_GET['request_id']);
if (!defined('VERIFY_REQUEST_ID')) {
define('VERIFY_REQUEST_ID', isset($argv[1])? $argv[1]: $_GET['request_id']);
}


error_log('Cancelling `request_id` ' . REQUEST_ID);
error_log('Cancelling `request_id` ' . VERIFY_REQUEST_ID);

$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));

try {
$result = $client->verify()->cancel(REQUEST_ID);
$result = $client->verify()->cancel(VERIFY_REQUEST_ID);
var_dump($result->getResponseData());
}

Expand Down
2 changes: 1 addition & 1 deletion verify/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));

$request = new \Vonage\Verify\Request(NUMBER, BRAND_NAME);
$request = new \Vonage\Verify\Request(VERIFY_NUMBER, VERIFY_BRAND_NAME);

// choose PIN length (4 or 6)
$request->setCodeLength(4);
Expand Down
26 changes: 13 additions & 13 deletions verify/request_with_workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
Sends a verification request and allows setting a Workflow ID

Usage:
php request_with_workflow.php -n <NUMBER> [-b <BRAND_NAME>] [-w <WORKFLOW_ID>]
php request_with_workflow.php -n <VERIFY_NUMBER> [-b <VERIFY_BRAND_NAME>] [-w <VERIFY_WORKFLOW_ID>]

NUMBER the telephone number to send the Verify request to
BRAND_NAME is the name of the company sending the request. Defaults to 'Acme, Inc.'
WORKFLOW_ID is the workflow ID to use. Must be between 1-5
VERIFY_NUMBER the telephone number to send the Verify request to
VERIFY_BRAND_NAME is the name of the company sending the request. Defaults to 'Acme, Inc.'
VERIFY_WORKFLOW_ID is the workflow ID to use. Must be between 1-5

Options can also be passed as environment variables.

Expand All @@ -25,28 +25,28 @@
exit(1);
}

if (!defined('NUMBER')) {
define('NUMBER', (array_key_exists('n', $options)) ? $options['n'] : null);
if (!defined('VERIFY_NUMBER')) {
define('VERIFY_NUMBER', (array_key_exists('n', $options)) ? $options['n'] : null);
}

if (!defined('BRAND_NAME')) {
define('BRAND_NAME', (array_key_exists('b', $options)) ? $options['b'] : 'Acme, Inc');
if (!defined('VERIFY_BRAND_NAME')) {
define('VERIFY_BRAND_NAME', (array_key_exists('b', $options)) ? $options['b'] : 'Acme, Inc');
}

if (!defined('WORKFLOW_ID')) {
define('WORKFLOW_ID', (array_key_exists('w', $options)) ? $options['w'] : 4);
if (!defined('VERIFY_WORKFLOW_ID')) {
define('VERIFY_WORKFLOW_ID', (array_key_exists('w', $options)) ? $options['w'] : 4);
}

if (is_null(NUMBER)) {
echo "Please supply a NUMBER to send a verification request to."
if (is_null(VERIFY_NUMBER)) {
echo "Please supply a VERIFY_NUMBER to send a verification request to."
. PHP_EOL
. PHP_EOL
. $helpText
;
exit(1);
}

$request = new \Vonage\Verify\Request(NUMBER, BRAND_NAME, (int) WORKFLOW_ID);
$request = new \Vonage\Verify\Request(VERIFY_NUMBER, VERIFY_BRAND_NAME, (int) VERIFY_WORKFLOW_ID);
$response = $client->verify()->start($request);

echo "Started verification, `request_id` is " . $response->getRequestId();
14 changes: 7 additions & 7 deletions verify/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
Searches for a verify request

Usage:
php search.php <REQUEST_ID>
php search.php <VERIFY_REQUEST_ID>

REQUEST_ID is the ID of a verification event
VERIFY_REQUEST_ID is the ID of a verification event

ENDHELP;

Expand All @@ -21,12 +21,12 @@
exit(1);
}

if (!defined('REQUEST_ID')) {
define('REQUEST_ID', (array_key_exists(1, $argv)) ? $argv[1] : null);
if (!defined('VERIFY_REQUEST_ID')) {
define('VERIFY_REQUEST_ID', (array_key_exists(1, $argv)) ? $argv[1] : null);
}

if (is_null(REQUEST_ID)) {
echo "Please supply a REQUEST_ID to search for."
if (is_null(VERIFY_REQUEST_ID)) {
echo "Please supply a VERIFY_REQUEST_ID to search for."
. PHP_EOL
. PHP_EOL
. $helpText
Expand All @@ -35,7 +35,7 @@
}

try {
$result = $client->verify()->search(REQUEST_ID);
$result = $client->verify()->search(VERIFY_REQUEST_ID);
echo "Request has a status of " . $result->getStatus() . PHP_EOL;
} catch (\Vonage\Client\Exception\Request $e) {
error_log("Client error: " . $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion verify/send_psd2_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));

$request = new \Vonage\Verify\RequestPSD2(RECIPIENT_NUMBER, PAYEE_NAME, AMOUNT);
$request = new \Vonage\Verify\RequestPSD2(VERIFY_NUMBER, VERIFY_PAYEE_NAME, VERIFY_AMOUNT);
$response = $client->verify()->requestPSD2($request);

echo "Started verification, `request_id` is " . $response['request_id'];
30 changes: 15 additions & 15 deletions verify/send_psd2_request_with_workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
Sends a verification request and allows setting a Workflow ID

Usage:
php request_with_workflow.php -n <NUMBER> [-b <BRAND_NAME>] [-w <WORKFLOW_ID>]
php request_with_workflow.php -n <VERIFY_NUMBER> [-b <VERIFY_BRAND_NAME>] [-w <VERIFY_WORKFLOW_ID>]

NUMBER the telephone number to send the Verify request to
BRAND_NAME is the name of the company sending the request. Defaults to 'Acme, Inc.'
WORKFLOW_ID is the workflow ID to use. Must be between 1-5
VERIFY_NUMBER the telephone number to send the Verify request to
VERIFY_BRAND_NAME is the name of the company sending the request. Defaults to 'Acme, Inc.'
VERIFY_WORKFLOW_ID is the workflow ID to use. Must be between 1-5

Options can also be passed as environment variables.

Expand All @@ -25,31 +25,31 @@
exit(1);
}

if (!defined('RECIPIENT_NUMBER')) {
define('RECIPIENT_NUMBER', (array_key_exists('n', $options)) ? $options['n'] : null);
if (!defined('VERIFY_NUMBER')) {
define('VERIFY_NUMBER', (array_key_exists('n', $options)) ? $options['n'] : null);
}

if (!defined('PAYEE_NAME')) {
define('PAYEE_NAME', (array_key_exists('b', $options)) ? $options['b'] : 'Acme, Inc');
if (!defined('VERIFY_PAYEE_NAME')) {
define('VERIFY_PAYEE_NAME', (array_key_exists('b', $options)) ? $options['b'] : 'Acme, Inc');
}

if (!defined('AMOUNT')) {
define('AMOUNT', (array_key_exists('a', $options)) ? $options['a'] : '$10.00');
if (!defined('VERIFY_AMOUNT')) {
define('VERIFY_AMOUNT', (array_key_exists('a', $options)) ? $options['a'] : '$10.00');
}

if (!defined('WORKFLOW_ID')) {
define('WORKFLOW_ID', (array_key_exists('w', $options)) ? $options['w'] : 4);
if (!defined('VERIFY_WORKFLOW_ID')) {
define('VERIFY_WORKFLOW_ID', (array_key_exists('w', $options)) ? $options['w'] : 4);
}

if (is_null(RECIPIENT_NUMBER)) {
echo "Please supply a NUMBER to send a verification request to."
if (is_null(VERIFY_NUMBER)) {
echo "Please supply a VERIFY_NUMBER to send a verification request to."
. PHP_EOL
. PHP_EOL
. $helpText;
exit(1);
}

$request = new \Vonage\Verify\RequestPSD2(RECIPIENT_NUMBER, BRAND_NAME, AMOUNT, (int) WORKFLOW_ID);
$request = new \Vonage\Verify\RequestPSD2(VERIFY_NUMBER, VERIFY_PAYEE_NAME, VERIFY_AMOUNT, (int) VERIFY_WORKFLOW_ID);
$response = $client->verify()->requestPSD2($request);

echo "Started verification, `request_id` is " . $response['request_id'];
6 changes: 3 additions & 3 deletions verify/trigger_next_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
require_once __DIR__ . '/../vendor/autoload.php';

// Support direct execution from command line or via a GET request as a web server
define('REQUEST_ID', isset($argv[1])? $argv[1]: $_GET['request_id']);
define('VERIFY_REQUEST_ID', isset($argv[1])? $argv[1]: $_GET['request_id']);

error_log('Triggering next event for `request_id`' . REQUEST_ID);
error_log('Triggering next event for `request_id`' . VERIFY_REQUEST_ID);

$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));

$result = $client->verify()->trigger(REQUEST_ID);
$result = $client->verify()->trigger(VERIFY_REQUEST_ID);

var_dump($result->getResponseData());
12 changes: 6 additions & 6 deletions verify/verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
require_once __DIR__ . '/../vendor/autoload.php';

// Support direct execution from command line or via a GET request as a web server
if (!defined('REQUEST_ID')) {
define('REQUEST_ID', isset($argv[1])? $argv[1]: $_GET['request_id']);
if (!defined('VERIFY_REQUEST_ID')) {
define('VERIFY_REQUEST_ID', isset($argv[1])? $argv[1]: $_GET['request_id']);
}

if (!defined('CODE')) {
define('CODE', isset($argv[2])? $argv[2]: $_GET['pin_code']);
if (!defined('VERIFY_CODE')) {
define('VERIFY_CODE', isset($argv[2])? $argv[2]: $_GET['pin_code']);
}

error_log('Verifying code ' . CODE . ' is correct for request ' . REQUEST_ID);
error_log('Verifying code ' . VERIFY_CODE . ' is correct for request ' . VERIFY_REQUEST_ID);

$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));

$result = $client->verify()->check(REQUEST_ID, CODE);
$result = $client->verify()->check(VERIFY_REQUEST_ID, VERIFY_CODE);

var_dump($result->getResponseData());
4 changes: 2 additions & 2 deletions verify2/cancel-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$newRequest = new \Vonage\Verify2\Request\SMSRequest(TO_NUMBER, 'my-verification');
$newRequest = new \Vonage\Verify2\Request\SMSRequest(VERIFY_NUMBER, 'my-verification');

$client->verify2()->cancel(REQUEST_ID);
$client->verify2()->cancel(VERIFY_REQUEST_ID);
2 changes: 1 addition & 1 deletion verify2/check-verification-code.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
);

try {
$client->verify2()->check(REQUEST_ID, CODE);
$client->verify2()->check(VERIFY_REQUEST_ID, CODE);
} catch (\Exception $e) {
var_dump($e->getMessage());
}
2 changes: 1 addition & 1 deletion verify2/create-template-fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
'The authentication code for your ${brand} is: ${code}'
);

$client->verify2()->createCustomTemplateFragment(TEMPLATE_ID, $createFragmentRequest);
$client->verify2()->createCustomTemplateFragment(VERIFY_TEMPLATE_ID, $createFragmentRequest);
2 changes: 1 addition & 1 deletion verify2/delete-fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$client->verify2()->deleteCustomTemplateFragment(TEMPLATE_ID, TEMPLATE_FRAGMENT_ID);
$client->verify2()->deleteCustomTemplateFragment(VERIFY_TEMPLATE_ID, VERIFY_TEMPLATE_FRAGMENT_ID);
2 changes: 1 addition & 1 deletion verify2/delete-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$client->verify2()->deleteCustomTemplate(TEMPLATE_ID);
$client->verify2()->deleteCustomTemplate(VERIFY_TEMPLATE_ID);
2 changes: 1 addition & 1 deletion verify2/get-fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$fragment = $client->verify2()->getCustomTemplateFragment(TEMPLATE_ID, TEMPLATE_FRAGMENT_ID);
$fragment = $client->verify2()->getCustomTemplateFragment(VERIFY_TEMPLATE_ID, VERIFY_TEMPLATE_FRAGMENT_ID);
2 changes: 1 addition & 1 deletion verify2/get-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$template = $client->verify2()->getCustomTemplate(TEMPLATE_ID);
$template = $client->verify2()->getCustomTemplate(VERIFY_TEMPLATE_ID);
2 changes: 1 addition & 1 deletion verify2/list-fragments.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$fragment = $client->verify2()->listTemplateFragments(TEMPLATE_ID);
$fragment = $client->verify2()->listTemplateFragments(VERIFY_TEMPLATE_ID);
2 changes: 1 addition & 1 deletion verify2/list-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$template = $client->verify2()->listCustomTemplates(TEMPLATE_ID);
$template = $client->verify2()->listCustomTemplates(VERIFY_TEMPLATE_ID);
2 changes: 1 addition & 1 deletion verify2/send-request-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$newRequest = new \Vonage\Verify2\Request\EmailRequest(TO_EMAIL, 'my-verification');
$newRequest = new \Vonage\Verify2\Request\EmailRequest(VERIFY_TO_EMAIL, VERIFY_BRAND_NAME, VERIFY_FROM_EMAIL);
$client->verify2()->startVerification($newRequest);
2 changes: 1 addition & 1 deletion verify2/send-request-silent-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$newRequest = new \Vonage\Verify2\Request\SilentAuthRequest(TO_NUMBER, 'my-verification');
$newRequest = new \Vonage\Verify2\Request\SilentAuthRequest(VERIFY_NUMBER, 'my-verification');
$client->verify2()->startVerification($newRequest);
2 changes: 1 addition & 1 deletion verify2/send-request-sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$newRequest = new \Vonage\Verify2\Request\SMSRequest(TO_NUMBER, 'my-verification');
$newRequest = new \Vonage\Verify2\Request\SMSRequest(VERIFY_NUMBER, 'my-verification');
$client->verify2()->startVerification($newRequest);
2 changes: 1 addition & 1 deletion verify2/send-request-voice.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$newRequest = new \Vonage\Verify2\Request\VoiceRequest(TO_NUMBER, 'my-verification');
$newRequest = new \Vonage\Verify2\Request\VoiceRequest(VERIFY_NUMBER, 'my-verification');
$client->verify2()->startVerification($newRequest);
2 changes: 1 addition & 1 deletion verify2/send-request-whatsapp-interactive.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$newRequest = new \Vonage\Verify2\Request\WhatsAppInteractiveRequest(TO_NUMBER, 'my-verification');
$newRequest = new \Vonage\Verify2\Request\WhatsAppInteractiveRequest(VERIFY_NUMBER, 'my-verification');
$client->verify2()->startVerification($newRequest);
2 changes: 1 addition & 1 deletion verify2/send-request-whatsapp.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$newRequest = new \Vonage\Verify2\Request\WhatsAppRequest(TO_NUMBER, 'my-verification');
$newRequest = new \Vonage\Verify2\Request\WhatsAppRequest(VERIFY_NUMBER, 'my-verification');
$client->verify2()->startVerification($newRequest);
4 changes: 2 additions & 2 deletions verify2/send-request-with-fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);

$newRequest = new \Vonage\Verify2\Request\SilentAuthRequest(TO_NUMBER, 'my-verification');
$emailWorkflow = new \Vonage\Verify2\VerifyObjects\VerificationWorkflow(\Vonage\Verify2\VerifyObjects\VerificationWorkflow::WORKFLOW_EMAIL, TO_EMAIL);
$newRequest = new \Vonage\Verify2\Request\SilentAuthRequest(VERIFY_NUMBER, 'my-verification');
$emailWorkflow = new \Vonage\Verify2\VerifyObjects\VerificationWorkflow(\Vonage\Verify2\VerifyObjects\VerificationWorkflow::WORKFLOW_EMAIL, VERIFY_TO_EMAIL);
$newRequest->addWorkflow($emailWorkflow);
$client->verify2()->startVerification($newRequest);
Loading