In addition to the NewsMAN API, there is another way to retrieve information from NewsMAN. You can choose to receive notifications (webhooks) when certain events occur: imports, unsubscribes, spam reports, and bounces.
To activate this option you must enter the corresponding list in the Settings -> List menu :

The corresponding options are WebHook URL and Webhook Events :

- Next to WebHook URL you must enter a link to which the data will be sent, for example https://www.example.com/retriving-informations-newsman-webhooks, The link should be on HTTPS.
- The Webhook Events option allows you to choose what data will be sent. By default, data about imports and newsletters is sent but you can also choose unsubscribes or bounces .
After you have activated webhooks you will start receiving events (notifications) like this:
- Requests will be of type POST
- Each request will contain a JSON encoded string named newsman_events . The JSON encoded string is an array of events (one or more NewsMAN events).
- Each event will contain the following fields: type (import, newsletter_status, unsub, spam or bounce), timestamp (event date) and date (an array with information that differs depending on the event type)
Below you can see an example for import:
<?php print_r($_POST); /* Array ( [newsman_events] =--> [{"type":"import","timestamp":1372428476,"data":{"import_id":"51cd98951fbbbf972d000001","status":"finished"}}] ( */ $newsman_events = json_decode($_POST["newsman_events"]); print_r($newsman_events[0]); /* Array ( [type] => import [timestamp] => 1372428476 [data] => Array ( [import_id] => 51cd98951fbbbf972d000001 [status] => finished ) ) */ ?>
Below you can see what information is sent depending on the type of event:
import : import_id (can be read via API ), status
newsletter_status: newsletter _ id , status
unsub : newsletter_id , subject , list_id , subscriber_id , email
spam : newsletter_id , subject , list_id , subscriber_id , email
bounce : newsletter_id , subject , list_id, subscriber_id , email , email_head (the entire bounce message), diag_msg (short description of the bounce), hard_bounce (if the bounce is hardbounce)