Answer:How to post data in PHP using file_get_contents?

$postdata = http_build_query(
array(
‘var1’ => ‘some content’,
‘var2’ => ‘doh’
)
);
$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(‘http://example.com/submit.php’, false, $context);


http://stackoverflow.com/a/2445332

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.