当前位置:首页 > Web开发 > 正文

PHP CURL设置Authorization

2024-03-31 Web开发

标签:

$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);

PHP CURL设置Authorization

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/41884.html