PHP Class DrewM\MailChimp\Webhook

How to Set Up Webhooks: http://eepurl.com/bs-j_T
Author: Drew McLellan ([email protected])
显示文件 Open project: drewm/mailchimp-api Class Usage Examples

Public Methods

Method Description
receive ( string $input = null ) : array | false Retrieve the incoming webhook request as sent.
subscribe ( string $event, callable $callback ) : void Subscribe to an incoming webhook request. The callback will be invoked when a matching webhook is received.

Private Methods

Method Description
dispatchWebhookEvent ( string $event, array $data ) : void Call any subscribed callbacks for this event
processWebhook ( string $input ) : array | false Process the raw request into a PHP array and dispatch any matching subscription callbacks

Method Details

receive() public static method

Retrieve the incoming webhook request as sent.
public static receive ( string $input = null ) : array | false
$input string An optional raw POST body to use instead of php://input - mainly for unit testing.
return array | false An associative array containing the details of the received webhook

subscribe() public static method

Subscribe to an incoming webhook request. The callback will be invoked when a matching webhook is received.
public static subscribe ( string $event, callable $callback ) : void
$event string Name of the webhook event, e.g. subscribe, unsubscribe, campaign
$callback callable A callable function to invoke with the data from the received webhook
return void