简体   繁体   English

这是此CURL行的正确PHP版本吗?

[英]Is this the correct PHP version of this CURL line?

Sorry if this is obvious - I'm just not sure I have it right. 抱歉,如果这很明显-我不确定我是否正确。 I don't get any response back when testing. 测试时我没有得到任何回应。 Is the below the correct conversion of the CURL script to PHP? 下面是CURL脚本到PHP的正确转换吗?

curl -X POST -u $APIKEY:$APISECRET \ https://api.application.io/v1/project/<projectname>

if APIKEY = 1234 and APISECRET = 1234 如果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);

as it's basic authentication you want: 因为它是您想要的基本身份验证:

curl_setopt($curl, CURLOPT_HTTPHEADER,
            array(
              "Authorization: Basic " . base64_encode("$APIKEY:$APISECRET")
));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM