Ошибка публикации Webhook от провайдера, но в Postman это работает [дубликат] ⇐ Php
-
Anonymous
Ошибка публикации Webhook от провайдера, но в Postman это работает [дубликат]
I am trying to do an integration with a provider that will post data to me, using PHP. I wrote this baseline function to test:
public function dumpanddie($x = null) { $r = $_REQUEST; if (empty($r)) { $r = $_POST; } if (empty($r)) { $r = $_GET; } if (empty($r) && !empty($x)) { $r = $x; } if (empty($r)) { header('HTTP/1.1 400 Bad Request', true, 400); exit(); } $dumpdata = ['dumpdata' => (is_array($r) ? json_encode($r) : $r)]; $this->db->insert('dam_dumpanddie', $dumpdata); header("HTTP/1.1 200 OK"); exit(); } Now - what is happening here, is that the provider's service is triggering the 400 error.
When I run this in Postman, I get the database entry inserted successfully, and a 200 response.
It appears as if $_POST, $_GET and $_REQUEST are all empty when running the call via the provider's portal. I do not have CSRF protection in place within this controller, so it should not be that. What else could cause something like this?
The webhook is from Vital, the healthcare device integration platform, and they have a test tool that can send some sample data to check that your endpoint is correct.
If this code is confirmed correct by respondents here (which I think it is, but bloated, because I kept getting the 400 error) then it would be a question for their support department, but perhaps someone can see something I am doing wrong (besides using raw data from source - this is PoC)?
Источник: https://stackoverflow.com/questions/780 ... n-it-works
I am trying to do an integration with a provider that will post data to me, using PHP. I wrote this baseline function to test:
public function dumpanddie($x = null) { $r = $_REQUEST; if (empty($r)) { $r = $_POST; } if (empty($r)) { $r = $_GET; } if (empty($r) && !empty($x)) { $r = $x; } if (empty($r)) { header('HTTP/1.1 400 Bad Request', true, 400); exit(); } $dumpdata = ['dumpdata' => (is_array($r) ? json_encode($r) : $r)]; $this->db->insert('dam_dumpanddie', $dumpdata); header("HTTP/1.1 200 OK"); exit(); } Now - what is happening here, is that the provider's service is triggering the 400 error.
When I run this in Postman, I get the database entry inserted successfully, and a 200 response.
It appears as if $_POST, $_GET and $_REQUEST are all empty when running the call via the provider's portal. I do not have CSRF protection in place within this controller, so it should not be that. What else could cause something like this?
The webhook is from Vital, the healthcare device integration platform, and they have a test tool that can send some sample data to check that your endpoint is correct.
If this code is confirmed correct by respondents here (which I think it is, but bloated, because I kept getting the 400 error) then it would be a question for their support department, but perhaps someone can see something I am doing wrong (besides using raw data from source - this is PoC)?
Источник: https://stackoverflow.com/questions/780 ... n-it-works
Мобильная версия