Skip to content

Instantly share code, notes, and snippets.

@icuy
Last active January 22, 2018 03:30
Show Gist options
  • Select an option

  • Save icuy/595d5d3219f665f0b44242e46dc984bf to your computer and use it in GitHub Desktop.

Select an option

Save icuy/595d5d3219f665f0b44242e46dc984bf to your computer and use it in GitHub Desktop.
Create POST request
function postRequest($postdata,$url)
{
$postdata = http_build_query($postdata);
$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($url, false, $context);
}
$url = 'http://0oor.com/';
$postdata = array('key' => 'value');
postRequest($postdata,$url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment