How to implement a post request forwarding to another address in php?

Viewed 21

How to implement in php the forwarding of a post request to another address and return a response? Let's say I send POST data to one site (to its php file), and it redirects it to another and gives me an answer to the original site.

I tried it like this, but I didn't get an answer:

<?php
$indata = file_get_contents("php://input"); 

$newdata = array(
        "http" => array(
                "method" => "POST",
                "header" => 
                    "HTTP/1.1" . "\r\n" .
                    "Content-Type: application/json" . "\r\n" .
                    "Content-Length: " . strlen($indata) . "\r\n",
                    "Content" => $indata,
        ),
);

$outdata = file_get_contents("//webclient.gamecluster.nextrp.ru/login", false, stream_context_create($newdata));

file_put_contents("php://output", $outdata);
?>
0 Answers
Related