我正在使用Web上的API开发应用程序。在网络上,我需要提供http响应,因为它们会将POST请求发送到我的系统。
像这样
第一步,我可以发送响应并保存到我的数据库中,像这样的代码
public function notification_kredivo_v_2(){
//set response
ignore_user_abort(true);
set_time_limit(0);
ob_start();
//data response
header('Content-Type: application/json; charset=utf-8');
$default = array(
"status" => "OK",
"message" => "Notification has been received",
);
echo json_encode($default);;
// DON'T USE CONTENT-LENGTH or IT WILL BREAK THE CODE
header('Connection: close');
header('Content-Length: '.ob_get_length());
ob_end_flush();
ob_flush();
flush();
//load db
$this->load->model('kredivo_model', 'km');
//ambil data result
$result = json_decode(file_get_contents('php://input'), true);
$order_id = $result['order_id'];
$transaction_id = $result['transaction_id'];
$signature_key = $result['signature_key'];
//masukan ke database kredivo payment
$this->km->confirm_payment_v2(
$order_id,
$transaction_id,
$signature_key
);
}
但是在该过程之后,我必须将GET请求发送到另一个系统,我的代码是这样的,我使用guzzle来获取请求
/*CONFIRM TO V2/UPDATE*/
//kirim get untuk confirm order
$url = $this->ci->config->item("kredivo_api_link_confirm");
//load libary kredivo
$this->load->library('CoreKredivo','corekredivo');
//sent to v2/update
$confirm_order = array(
'transaction_id' => $transaction_id,
'signature_key' => $signature_key,
);
//kirim data ke confirmation core kredivo
$confirmation = $this->corekredivo->confirmOrder($url,$confirm_order);
//menerima data dari core kredivo dan melakukan decode
$finalResponse_payment = json_decode($confirmation,true);
$fraud = $finalResponse_payment['fraud_status'];
$transaction_status = $finalResponse_payment['transaction_status'];
$user_token = $finalResponse_payment['user_token'];
$this->km->confirm_payment_v2(
$fraud,
$transaction_status,
$user_token
);
我尝试保存到数据库以检查我的获取请求是否正在运行
但是由于数据没有插入到我的数据库中,因此get请求无法正常工作
如何解决这个问题?请帮助