Receiving Data from Webhook and Email ID

Hi,

I am fairly new to webhooks can someone help me with a very simple piece of code to show my webhook working in php

I have received a valid response using request bin, so I wanted to make it send me the ID of the Deal via email

php

$result = $_REQUEST[‘current’]; // Using Request bin this seemed to be the array holding the info
$obj = json_decode($result, true);
$forEmail = $obj[‘id’];

$emailfrom = “xxx”; //Sender or From Email
$emailto = “xxx”;
$subject = “You’ve got a new zoom tour booking”;
$headers = "From: " . $emailfrom . “\r\n”;
$headers .= "Reply-To: ". $emailfrom . “\r\n”;

$headers .= “MIME-Version: 1.0\r\n”;

$headers .= “Content-Type: text/html; charset=utf-8\r\n”;
$body = “Hi,”.$forEmail;
@mail($emailto, $subject, $body, $headers);

Can you assist me where I am going wrong, if I copy the response directly into the $result I can use it with no issue. I believe the problem lies with the $_REQUEST

This maybe a very simple question for someone, so any help greatly appreciated.

Thanks in advance,

Ian

I have found an answer to this

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

This receives the response from the webhook successfully

1 Like