$options = array(
'http' => array(
'header' => "Content-Type: application/json\r\n" .
"Authorization: Bearer your_access_token\r\n"
)
);
$context = stream_context_create($options);
$options = array(
'http' => array(
'proxy' => 'tcp://proxy.example.com:8080',
'request_fulluri' => true
)
);
$context = stream_context_create($options);
$options = array(
'http' => array(
'timeout' => 10 // 設置超時時間為10秒
)
);
$context = stream_context_create($options);
$options = array(
'ssl' => array(
'verify_peer' => true,
'cafile' => '/path/to/ca_cert.pem'
)
);
$context = stream_context_create($options);
$file_path = '/path/to/file.txt';
$file_contents = file_get_contents($file_path);
$options = array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: application/octet-stream\r\n",
'content' => $file_contents
)
);
$context = stream_context_create($options);