Ad
Getting Header Info Through Php://input
I am trying to get my webhooks header (Woocommerce webhook),
I am retrieving the body with file_get_contents('php://input'), although this only gives the body according to http://php.net/manual/en/wrappers.php.php
I also found this thread: link, but I can't figure it out. Is there any other function that gives me back the header?
My function looks like this:
public function webhook(Request $request) {
$json = file_get_contents('php://input');
Storage::disk('local')->put('file.txt', $json);
}
Edit: Other things I tried:
public function webhook(Request $request) {
$json = file_get_contents('php://input');
$headers = getallheaders();
Storage::disk('local')->put('file.txt', $headers['Content-Name']);
}
This sets the webhook to "Disabled", I suppose this throws an error for some reason.
apache_request_headers
is not changing the status to "Disabled" but is returning an empty file.txt
Ad
Answer
For the ones who might be facing the same problem in the future, I found the following solution:
public function webhook(Request $request) {
$json = file_get_contents('php://input');
Storage::disk('local')->put('file.txt', $json);
Storage::disk('local')->put('request.txt', Request::header('x-wc-webhook-source'));
}
Main url solution: Link
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad