我已经搜索了几个小时,但我仍然不知道PHP中的“流上下文”是什么。我正在尝试使用一个API,它涉及使用这个“流上下文”。
文档说:
上下文是一组参数和特定于包装器的选项,可以修改或增强流的行为。
- 哪种参数?
- 什么是“特定于包装器”的选项?
- 什么流?
这是我所说的代码:
// Encode the credentials and create the stream context.
$auth = base64_encode("$acctKey:$acctKey");
$data = array(
'http' => array(
'request_fulluri' => true,
// ignore_errors can help debug – remove for production. This option added in PHP 5.2.10
'ignore_errors' => true,
'header' => "Authorization: Basic $auth")
);
$context = stream_context_create($data);
// Get the response from Bing.
$response = file_get_contents($requestUri, 0, $context);