2014-07-11 86 views
0

對不起,如果這是顯而易見的 - 我只是不知道我是否正確。測試時我沒有收到任何迴應。下面是CURL腳本到PHP的正確轉換嗎?這是這個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); 

回答

1

,因爲它是你想要的基本身份驗證:

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