kirill578 Posted February 25, 2011 Share Posted February 25, 2011 How do I send multiple headers with this code? <?php $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); ?> *this header: User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16 Link to comment https://forums.phpfreaks.com/topic/228780-send-post-request-with-multiple-headers/ Share on other sites More sharing options...
trq Posted February 25, 2011 Share Posted February 25, 2011 Separate the with "\r\n" within the 'header' index. Link to comment https://forums.phpfreaks.com/topic/228780-send-post-request-with-multiple-headers/#findComment-1179468 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.