html - send response HTTP 200 SUCCESS in php -
i need send http 200 response string 'success', php server version 5.2.17!
in case, webhook sends data capture file called notification.php, read contentes, save in database , need send response not know how this!
does know how in php 5.2.17?
i tried following ways without success:
// error 1 header("content-type: text/plain"); echo "success"; // error 2 $httpstatuscode = 200; $httpstatusmsg = 'success'; $protocol = isset($_server['server_protocol']) ? $_server['server_protocol'] : 'http/1.0'; header($protocol.' '.$httpstatuscode.' '.$httpstatusmsg); // error 3 header("200 success"); return "200 success"; // error 4 header('content-type: application/json'); echo 'success'; // error 5 header('content-type: application/json'); return 'success'; //error 6 header('content-type: application/json'); header('success'); ///error 7 header('content-type: application/json'); $success =json_encode('success'); header($success); ///error 8 header("http/1.1 200 success"); header("content-type:application/json; charset=utf-8"); ///error 9 header("http/1.1 200"); header("content-type:application/json; charset=utf-8"); result 'success'; //error 10 header("content-type:application/json;"); header('http/1.0 200 success'); // error 11 $code = 200; $text = 'ok'; $protocol = (isset($_server['server_protocol']) ? $_server['server_protocol'] : 'http/1.0'); header($protocol . ' ' . $code . ' ' . $text); $globals['http_response_code'] = $code; echo 'success';
my phpcode
<?php $src_data = $_request["data"]; $une_data = stripslashes($src_data); $data = json_decode($une_data); //get payment data $id_cob = $data->payment->id; $id_cus = $data->payment->customer; $status = $data->payment->status; $dtsts = date("y-m-d"); if ($data->event == 'payment_received') { // post client include('dbconnection.php'); $qryn = "update payments set status='$status', datastatus='$dtsts' id_cob_asaas='$id_cob' , id_cli_asaas='$id_cus'"; mysql_query($qryn,$cnx); } // webhook return // solution was: header('http/1.1 200 ok'); echo 'success'; return; ?>
try:
$code = 200; $text = 'ok'; $protocol = (isset($_server['server_protocol']) ? $_server['server_protocol'] : 'http/1.0'); header($protocol . ' ' . $code . ' ' . $text); $globals['http_response_code'] = $code; echo 'success';
Comments
Post a Comment