curl 없이 post 데이터 주고 받기

php 2016.05.31 12:27

[원문] http://stackoverflow.com/questions/8596311/how-to-make-a-post-request-without-curl


$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);


Trackback 0 : Comment 0