webhooks()

List of all webhooks (array) is obtained.

webhooks() : array
Information obtained

Array of webhooks. Each webhook is represented as an array that includes:

  • id - webhook ID that is used in other API functions
  • web_id - webhook ID that is used in the administration page
  • title - name of webhook
  • create_time - GMT date of webhook creation given in YYYY-MM-DD HH:II:SS format
  • list_id - list ID that the webhook is based on
  • list_name - list name that the webhook is based on
  • last_event - GMT date of last triggered successful event given in YYYY-MM-DD HH:II:SS format
  • total_events - number of total successful event triggered
  • status - flag that indicates the status of the webhook (enabled / disabled)
  • url - URL where requests are delivered to
  • secret_key - secret key that is passed in every webhook request you receive. It gives you the opportunity to verify that requests originated from us.
  • events - array of events used to trigger the webhook. Possible values are: contact.subscribe, contact.unsubscribe, contact.update, email.change, email.bounce, email.open, email.click.
  • sources - array of sources used to trigger the webhook. Possible values are: subscriber, admin, api

Examples

mgapi_webhooks.php
<?php
/**
This Example shows how to webhoks using the MGAPI.php class and do some basic error checking.
**/
require_once 'inc/MGAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey

$api = new MGAPI($apikey);

$retval = $api->webhooks();

header("Content-Type: text/plain");
if ($api->errorCode){
	echo "Unable to load webhooks()!";
	echo "\tCode={$api->errorCode}\n";
	echo "\tMsg={$api->errorMessage}\n";
} else {
	echo sizeof($retval) . " Webhooks Returned:\n";
	foreach($retval as $c){
		echo "Webhook Id: {$c['id']} - {$c['title']}\n";
		echo "\tLast event: {$c['last_event']}\n";
		echo "\tTotal events: {$c['total_events']}\n";
	}
}

© 2010-2018 Mailigen. All rights reserved.