oncode
3/13/2014 - 7:52 PM

Get file contents using a POST request.

Get file contents using a POST request.

<?php
 
$url = 'http://url.com/file.php';
$data = array('param1' => 'value1', 'param2' => 'value2');
 
$options = array(
  'http' => array(
    'header' => "Content-type: application/x-www-form-urlencoded\r\n",
    'method' => 'POST',
    'content' => http_build_query($data),
  ),
);

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);