1. Go to this page and download the library: Download belisoful/prado-webhooks 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/ */
belisoful / prado-webhooks example snippets
public function init($config)
{
parent::init($config);
$this->getApplication()->onInitComplete[] = function () {
// Null on any request another service is handling, which is most of them.
$service = TWebhookService::getInstance();
if ($service === null) {
return;
}
$service->onWebhook[] = [$this, 'anyWebhook']; // every endpoint's accepted deliveries
$service->onRefused[] = [$this, 'countRefusal']; // and the ones an endpoint turned away
if (($github = $service->getEndpoint('github')) !== null) {
$github->onWebhook[] = [$this, 'github'];
}
};
}
public function github(TWebhookEndpoint $sender, TWebhookEventParameter $param): void
{
if ($param->getEvent() !== 'push') {
return;
}
$this->queueDeploy($param['repository']['full_name'], $param['after']);
$param->setStatusCode(202);
}
// the secret goes into the queue table with the delivery
$webhooks->queue([['url' => $row['url'], 'secret' => $row['secret']]], $payload, 'invoice.paid');
// or queue a reference, and put the target back on the way out
$webhooks->queue([['url' => $row['url'], 'data' => $row['id']]], $payload, 'invoice.paid');
$webhooks->onDequeue[] = function ($sender, TWebhookQueueItem $item) {
$target = TWebhookTarget::ensure($item->getTargetSpec());
$target->setSignature($this->signerFor($item->getTargetSpec()['data']));
$item->setTarget($target);
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.