Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

php - CallRail Webhook

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

question from:https://stackoverflow.com/questions/66055566/callrail-webhook

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...