php - CallRail Webhook
Get the solution ↓↓↓I am trying to set up a webhook from callrails platform. According to CallRail documentation it appears that my endpoint should response with a HTTP status code of 200? I've done webhooks before but never seen this one before. I am not getting anything after a call is made.
From call rails docs "Your endpoint should respond with a HTTP status code of 2xx to indicate that the data was received properly. In general, a response status code other than 2xx indicates that the webhook was unable to complete the requested action."
This is the php code I am using. I just want to see the data being posted. Is there something I need to add to properly respond with 200 status code?
include('common.php');
if(!empty($_POST))
{
foreach($_POST as $key => $value)
{
$msg .= 'Key: ' . $key . ' => ' . $value . '<br>';
}
$ret = runner_mail(array('to' => 'xxxx', 'subject' => 'Callrail Call POST', 'htmlbody' => $msg));
$data = json_decode($_POST['body'], true);
if(!empty($data))
{
foreach($data as $key => $value)
{
$message .= 'Key: ' . $key . ' => ' . $value . '<br>';
}
$ret = runner_mail(array('to' => 'xxxxxx', 'subject' => 'Callrail Body Data', 'htmlbody' => $message));
}
}
Thanks for your feedback
Answer
Solution:
for anyone that wants to know here is the answer.
$payload = @file_get_contents('php://input');
$call = json_decode($payload);
//process data
http_response_code(200);
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: dompdf image not found or type unknown
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.