get下载图片
<?phppost Authorization验证
//请求地址
$url = "http://i.meizitu.net/2017/11/18b35.jpg";
//headers请求头
$context_options = array(
'http' =>
array(
'method' => "GET",
'header' => "User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36\r\nReferer:http://www.mzitu.com/\r\n",
));
$context = stream_context_create($context_options);
//获取资源
$img = file_get_contents($url,FALSE,$context);
//保存
file_put_contents("imageName.jpg",$img);
<?php
$opts = array('http' =>
array(
'method' => 'POST',
'header' => "Content-Type: text/xml\r\n".
"Authorization: Basic ".base64_encode("$https_user:$https_password")."\r\n",
'content' => $body,
'timeout' => 60
)
);
$context = stream_context_create($opts);
$url = 'https://'.$https_server;
$result = file_get_contents($url, false, $context, -1, 40000);
?>
网友回复