PHP code example of jmsfwk / lumen-webhook-server

1. Go to this page and download the library: Download jmsfwk/lumen-webhook-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/ */

    

jmsfwk / lumen-webhook-server example snippets


$app->register(Jmsfwk\WebhookServer\WebhookServerServiceProvider::class);

WebhookCall::create()
   ->url('https://other-app.com/webhooks')
   ->payload(['key' => 'value'])
   ->useSecret('sign-using-this-secret')
   ->dispatch();

// payload is the array passed to the `payload` method of the webhook
// secret is the string given to the `signUsingSecret` method on the webhook.

$payloadJson = json_encode($payload); 

$signature = hash_hmac('sha256', $payloadJson, $secret);

namespace Spatie\WebhookServer\Signer;

interface Signer
{
    public function signatureHeaderName(): string;

    public function calculateSignature(array $payload, string $secret): string;
}

WebhookCall::create()
    ->signUsing(YourCustomSigner::class)
    ...
    ->dispatch();

WebhookCall::create()
    ->timeoutInSeconds(5)
    ...
    ->dispatch();

WebhookCall::create()
    ->maximumTries(5)
    ...
    ->dispatch();

namespace Spatie\WebhookServer\BackoffStrategy;

interface BackoffStrategy
{
    public function waitInSecondsAfterAttempt(int $attempt): int;
}

WebhookCall::create()
    ->useBackoffStrategy(YourBackoffStrategy::class)
    ...
    ->dispatch();

WebhookCall::create()
    ->useHttpVerb('get')
    ...
    ->dispatch();

WebhookCall::create()
    ->withHeaders([
        'Another Header' => 'Value of Another Header'
    ])
    ...
    ->dispatch();

WebhookCall::create()
    ->doNotVerifySsl()
    ...
    ->dispatch();

WebhookCall::create()
    ->meta($arrayWithMetaInformation)
    ...
    ->dispatch();

WebhookCall::create()
    ->withTags($tags)
    ...
    ->dispatch();