How to make a request for 2 domains via PHP via POST?

How can this be done?

There is a Client, Server1, Server2. The client sends a POST request to Server1. Server1 processes variables from POST and makes a request to Server2 based on the processed data. Having received a response from Server2, Server1 finishes processing the request from the Client and issues a response page to it. Those. Server1 should respond to the Client ONLY after receiving a response from Server2 of a request from Server1. Please provide some example code.

Thanks in advance!

Answer 1, authority 100%

I can give you a diagram of how to do it.

  1. Client sent data for example via ajax…
  2. Here, server1 has processed the data and sent it to another server2 using cURL and waits for something to come from server2 and as soon as something has arrived, server1 sends the data back to the client.