1. Go to this page and download the library: Download viewmend/sdk 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/ */
viewmend / sdk example snippets
declare(strict_types=1);
use ViewMend\ViewMend;
alse || trim($token) === '') {
throw new \RuntimeException('VIEWMEND_API_TOKEN is throw new \RuntimeException('VIEWMEND_INTEGRATION_ID is ',
title: 'Homepage deployed',
)
->send();
use ViewMend\Exception\AuthenticationException;
use ViewMend\Exception\EndpointDisabledException;
use ViewMend\Exception\NetworkException;
use ViewMend\Exception\ServerException;
use ViewMend\Exception\TokenScopeException;
use ViewMend\ViewMend;
$cron = ViewMend::client(token: $token)->cron();
try {
$settings = $cron->current();
if ($settings === null) {
// No schedule has been registered. Show the initial settings form.
} else {
$cronExpression = $settings->cron;
$timezone = $settings->timezone;
$enabled = $settings->enabled;
// Display server state such as $settings->status and $settings->nextRunAt read-only.
}
} catch (TokenScopeException) {
// A Site Tracker token was pasted into the Cron settings.
} catch (AuthenticationException) {
// The Cron connection token is invalid or has been rotated.
} catch (EndpointDisabledException) {
// The ViewMend connection is disabled.
} catch (NetworkException|ServerException) {
// ViewMend is temporarily unavailable. Show a clearly marked cached snapshot if one exists.
}
$callback = $cron->verifyCallback($requestHeaders, $rawRequestBody);
if ($callback->isVerification()) {
$responseBody = $callback->verificationResponseBody();
// Return $responseBody as application/json with a 2xx status.
} else {
// Deduplicate by $callback->runId, then run the scheduled task.
// Return any 2xx response when processing succeeds.
}
printf(
"Delivery %s: event %s is %s (%s)\n",
$result->deliveryId->value,
$result->eventId->value,
$result->duplicate ? 'a duplicate' : 'accepted',
$result->queueStatus->value,
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.