Skip to content

Instantly share code, notes, and snippets.

@nissuk
Created October 24, 2011 17:13
Show Gist options
  • Save nissuk/1309544 to your computer and use it in GitHub Desktop.
Save nissuk/1309544 to your computer and use it in GitHub Desktop.
PHP: HTTPストリームコンテキスト+POSTの例
<?php
$url = 'http://localhost/example/test.php'; // <?php var_dump($_POST)
$params = array('foo' => 'bar');
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query($params, '', '&')
)
));
$contents = file_get_contents($url, false, $context);
echo $contents;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment