Home
> Uncategorized > HTTP POST using PHP
HTTP POST using PHP
$url = ‘https://posttestserver.com/post.php’;
$data = array(‘key1’ => ‘value1’, ‘key2’ => ‘value2’);
// use key ‘http’ even if you send the request to https://…
$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);
echo($result);
—- And the cool thing is that posttestserver.com lets you see what you posted to it. cool service!
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback