很抱歉,如果这很明显 - 我只是不确定我是否正确。测试时我没有收到任何回复。下面是CURL脚本到PHP的正确转换吗?
curl -X POST -u $APIKEY:$APISECRET \ https://api.application.io/v1/project/<projectname>
如果APIKEY = 1234且APISECRET = 1234
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"https://api.application.io/v1/project/myprojectname");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, "$12341234:$56785678");
curl_setopt($curl, CURLOPT_POST, 1);
$result = curl_exec ($curl);
curl_close ($curl);
print_r($result);
答案 0 :(得分:1)
因为它是您想要的基本身份验证:
curl_setopt($curl, CURLOPT_HTTPHEADER,
array(
"Authorization: Basic " . base64_encode("$APIKEY:$APISECRET")
));