PHP code example of nigel / freescout-webhook-parser

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

    

nigel / freescout-webhook-parser example snippets


use Nigel\FreescoutWebhookParser\FreeScoutWebhookParser;

// Get webhook data
$rawData = file_get_contents('php://input');

// Create parser instance
$parser = new FreeScoutWebhookParser($rawData);

// Parse the data
$result = $parser->parse();

// Get basic fields
$basicFields = $result->getBasicFields();

// Get all fields
$allFields = $result->getAllFields();

[
    'subject' => string,
    'body' => string,
    'from' => string,
    'to' => string,
    'date' => string,
    'type' => string,
    'status' => string,
    'customer' => [
        'name' => string,
        'email' => string
    ],
    'conversation_id' => string,
    'thread_id' => string
]

[
    'subject' => string,
    'body' => string,
    'from' => string,
    'to' => string,
    'cc' => string,
    'bcc' => string,
    'date' => string,
    'message_id' => string,
    'in_reply_to' => string,
    'references' => string,
    'attachments' => array,
    'headers' => array,
    'custom_fields' => array,
    'conversation_id' => string,
    'thread_id' => string,
    'type' => string,
    'status' => string,
    'customer' => [
        'id' => string,
        'name' => string,
        'email' => string
    ],
    'mailbox' => [
        'id' => string,
        'name' => string
    ],
    'user' => [
        'id' => string,
        'name' => string,
        'email' => string
    ],
    'dates' => [
        'created_at' => string,
        'updated_at' => string,
        'deleted_at' => string
    ],
    'tags' => array,
    'custom_data' => array,
    'meta' => array
]