PHP code example of brentnd / laravel-sparkposthooks

1. Go to this page and download the library: Download brentnd/laravel-sparkposthooks 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/ */

    

brentnd / laravel-sparkposthooks example snippets


use Brentnd\Api\Webhooks\SparkPostWebhookController;

class MySparkPostController extends SparkPostWebhookController {

    /**
     * Handle a bounced email
     *
     * @param $payload
     */
    public function handleMessageEventBounce($payload)
    {
        $email = $payload['rcpt_to'];
    }

    /**
     * Handle a rejected email
     *
     * @param $payload
     */
    public function handleMessageEventPolicyRejection($payload)
    {
        $email = $payload['rcpt_to'];
    }

    /**
     * Handle an email open
     *
     * @param $payload
     */
    public function handleTrackEventOpen($payload)
    {
        $transmissionId = $payload['transmission_id'];
    }
}

post('sparkpost-webhook', ['as' => 'sparkpost.webhook', 'uses' => 'MySparkPostController@handleWebhook']);