PHP CURL设置Authorization

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $linkUrl);

curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_setopt($ch, CURLOPT_FAILONERROR, false);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:application/x-www-form-urlencoded']);

//设置凭证
curl_setopt($ch, CURLOPT_USERPWD, 'user:pwd');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);

猜你喜欢

转载自www.cnblogs.com/codeninja/p/11969624.html
今日推荐