Skip to content
Prev Previous commit
Next Next commit
Updated Verify to work with v2.2.0
  • Loading branch information
dragonmantank committed Jun 25, 2020
commit b019ae4defafab27215d4a9ca5276d12f9126b76
7 changes: 5 additions & 2 deletions verify/cancel.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
<?php
require_once __DIR__ . '/../config.php';
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']);
if (!defined('REQUEST_ID')) {
define('REQUEST_ID', isset($argv[1])? $argv[1]: $_GET['request_id']);
}


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

Expand Down
9 changes: 5 additions & 4 deletions verify/request.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
<?php

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

$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic));

$verification = new \Nexmo\Verify\Verification(NUMBER, 'Acme Inc');
$client->verify()->start($verification);
$request = new \Nexmo\Verify\Request(NUMBER, BRAND_NAME);
$response = $client->verify()->start($request);

echo "Started verification, `request_id` is " . $verification->getRequestId();
echo "Started verification, `request_id` is " . $response->getRequestId();
6 changes: 3 additions & 3 deletions verify/request_with_workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
exit(1);
}

$verification = new \Nexmo\Verify\Verification(NUMBER, BRAND_NAME, ['workflow_id' => WORKFLOW_ID]);
$client->verify()->start($verification);
$request = new \Nexmo\Verify\Request(NUMBER, BRAND_NAME, (int) WORKFLOW_ID);
$response = $client->verify()->start($request);

echo "Started verification, `request_id` is " . $verification->getRequestId();
echo "Started verification, `request_id` is " . $response->getRequestId();
12 changes: 8 additions & 4 deletions verify/verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
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('CODE', isset($argv[2])? $argv[2]: $_GET['pin_code']);
if (!defined('REQUEST_ID')) {
define('REQUEST_ID', isset($argv[1])? $argv[1]: $_GET['request_id']);
}

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

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

$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
$client = new \Nexmo\Client(new \Nexmo\Client\Credentials\Container($basic));

$verification = new \Nexmo\Verify\Verification(REQUEST_ID);
$result = $client->verify()->check($verification, CODE);
$result = $client->verify()->check(REQUEST_ID, CODE);

var_dump($result->getResponseData());