Creating a webhook for updating emails as invalid or opt out

Hi!
I’m a newbie to SuiteCRM and I’ve really liked the environment so far! I’d like to get a bit aggressive and try to connect the mail sending service (SparkPost) web api to call an API in SuiteCRM.

I’m assuming the easiest way would be to create an entry point. Is there another alternative?

My code so far


<?php
  $entry_point_registry['SparkPostWebHook'] = array(
      'file' => 'custom/SparkPostWebHook.php',
      'auth' => true,
  );
  
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

$rawData = file_get_contents("php://input");

$sea = new SugarEmailAddress;

if (isset($rawData)) {
	print("inside\r\n");
	$issues = json_decode($rawData);

	foreach ($issues as $msg) {
		if ($msg->msys->message_event) {
			$class = "message_event";
			//$type = $msg->msys->message_event->type;
			//$recipient = $msg->msys->message_event->raw_rcpt_to;
			if ($msg->msys->message_event->type == "bounce") {
				$id = $sea->AddUpdateEmailAddress($msg->msys->message_event->raw_rcpt_to,1,0,null);
		} elseif ($msg->msys->message_event->type == "spam_complaint") {
				$id = $sea->AddUpdateEmailAddress($msg->msys->message_event->raw_rcpt_to,0,1,null);
		} else {
			$class = "unknown class";
		}
		
		echo " ok";
	}
	
} else {
	echo "Post not set";
}

Any comments would be appreciated!

thanks
John