Tag Archives: context

file_get_contents with context

$context = stream_context_create(array(
‘http’ => array(
‘method’ => ‘POST’,
‘header’ => //sprintf(“Authorization: Basic %s\r\n”, base64_encode($username.’:’.$password)).
“Content-type: application/x-www-form-urlencoded; ; charset=UTF-8\r\n” .
“User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6”
,
‘content’ => http_build_query(array(‘q’ => ‘đan ‘)),
‘timeout’ => 5,
),
));
$ret = file_get_contents(‘http://huypv.net/blog/application/index/search’, false, $context);