我正在使用由同学制作的API。我使用Postman为Authorization Basic生成用于连接的PHP cURL。这非常有效。现在,我想摆脱Authorization Basic并使用我自己的API Key&秘密(密码)。有没有什么好方法可以做到这一点?
提前致谢!
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "Some link here",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Basic //something here",
"cache-control: no-cache",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$result = json_decode($response,true);
}