H
H
happyer2019-07-16 18:16:03
PHP
happyer, 2019-07-16 18:16:03

Is it possible to receive callback on WP via php://input?

Hello, is it possible on the WP front to receive a callback from the api of another site via php://input ?
If so, how?
I tried to make a callback indicator by adding information to the file and everything worked correctly,
but when I wrote
$str = json_decode(file_get_contents('php://input'));
That file was empty

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shitprog, 2019-08-14
@shitprog

add an endpoint, for example domain.com/callback
like this:

$requestUri = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
    $requestUri = trailingslashit($requestUri);

    if ($requestUri === '/callback/') {
         // Обработка php://input
    }

an endpoint handler is hung on the wp hook in which you get php://input

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question