PHP code example of firstlogicmetalab / vact-server
1. Go to this page and download the library: Download firstlogicmetalab/vact-server library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
firstlogicmetalab / vact-server example snippets
use Vact\VactServer;
$vact = new VactServer(
getenv('VACT_APP_ID'),
getenv('VACT_APP_SECRET'),
);
// After YOUR login has decided who this is:
$token = $vact->createAccessToken(
userId: $currentUser->id,
allowedCalleeIds: ['user_42'], // optional: restrict who they may call
);
header('Content-Type: application/json');
echo json_encode(['accessToken' => $token['accessToken']]);
use function Vact\verifyVactWebhook;
use Vact\VactServerError;
$raw = file_get_contents('php://input');
try {
$event = verifyVactWebhook($raw, getallheaders(), getenv('VACT_WEBHOOK_SECRET'));
} catch (VactServerError $e) { // $e->errorCode is stable
http_response_code(400); // never process an unverified body
exit;
}
// Deduplicate on $event['eventId'] — delivery is retried.
if ($event['type'] === 'incoming_call') {
sendPush($event['data']['toUserId'], $event['data']);
}
http_response_code(200);
$result = $vact->deleteUserData($userId); // pages internally until complete
bash
php tests/run.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.