Skip to content

Instantly share code, notes, and snippets.

@goocey
Created March 2, 2017 08:16
Show Gist options
  • Save goocey/dfb7cc9a2e59e153442f93d526e914f1 to your computer and use it in GitHub Desktop.
Save goocey/dfb7cc9a2e59e153442f93d526e914f1 to your computer and use it in GitHub Desktop.
post request
<?php
$data = array(
'f&oo'=>'bar',
'baz'=>'bo/om',
'php'=>'hypertext processor'
);
$data = http_build_query($data, "", "&");
//header
$header = array(
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: ".strlen($data)
);
$context = array(
"http" => array(
"method" => "POST",
"header" => implode("\r\n", $header),
"content" => $data
)
);
echo 'request_body';
var_dump($data);
echo file_get_contents('https://domain/magazine/Gushi/index', false, stream_context_create($context));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment