V
V
Vic872020-06-14 04:46:20
WordPress
Vic87, 2020-06-14 04:46:20

How to accept an external (from another server) HTTP request on a WP site?

On the WP site, you need to accept and process an external HTTP request from the service (Yandex.Money) (POST method, MIME type - application/x-www-form-urlencoded).

I just can’t figure out where to place the handler and how to form a link to it in order to tell its service where it should send this very request.

A stupid solution, like creating a file with the wp-filename.php handler in the root and specifying https://mysite.ru/wp-filename.php as a link , does not work. Well, if only because all this is by WP and there is no access to the database, no hooks, no objects. Of course, you can connect to the database directly from this file via PDO, but this is all terribly crooked.

And how beautifully to implement - it is not thought out. Tell me, in which direction to think about the solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2020-06-14
@azerphoenix

I just can't figure out where to place the handler and how to form a link to it

Place in functions.php and create your own endpoint. Send requests to the specified endpoint
https://developer.wordpress.org/rest-api/extending...
To work with the database, use wpdb
https://wp-kama.ru/function/wpdb instead of PDO

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question