dhok
dhok

Reputation: 45

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 -X POST -u $APIKEY:$APISECRET \ https://api.application.io/v1/project/<projectname>

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

Upvotes: 0

Views: 64

Answers (1)

user557846
user557846

Reputation:

as it's basic authentication you want:

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

Upvotes: 1

Related Questions