Question Detail

I want to send data in file_get_contents post 


Thread Reply

Brijesh

- 8 months ago

$postdata = http_build_query(
    array(
        'var1' => 'some content',
        'var2' => 'doh'
    )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context  = stream_context_create($opts);

$result = file_get_contents('http://example.com/submit.php', false, $context);

Brijesh

- 8 months ago

$url = 'https://test.payumoney.com/payment/op/getPaymentResponse?merchantKey=SDfretD&merchantTransactionIds='.;


        $stream_options = array(
           'http' => array(
              'method'  => 'POST',
              'header'  => "authorization: dklfjdsoifu89yu43irhl\r\n"."cache-control: no-cache\r\n",
              
           ),
        );

        $context  = stream_context_create($stream_options);
        $response = file_get_contents($url, FALSE, $context);
        
        $obj = json_decode($response);