Hello!, I need to make a simple integration with Constant Contact to work.
I have an app registered:
https://app.constantcontact.com/pages/dma/portal/#application/5d01772e-d2a3-40b1-9098-8177e453697e
I have a Mashery account:
and I generated an authorization token:
I have a simple PHP/CULR based function which collects the data and sends it to Constant contact, as described here>
https://v3.developer.constantcontact.com/api_guide/contacts_create_or_update.html
The code is pretty simple:
$body = array(
"email_address" => $email_address,
"first_name" => $first_name,
"last_name" => $last_name,
"list_memberships"=>$list
);
$header=array();
$header[]="Content-Type: application/json";
$header[]="Authorization: Bearer ".$token;
$this->_log(json_encode($header),'Header: ');
$this->_log(json_encode($body),'Request: ');
$ch = curl_init("https://api.cc.email/v3/contacts/sign_up_form");
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$server_output = curl_exec($ch);
$this->_log($server_output,'Response: ');
curl_close($ch);
And the output also looks ok:
2021-02-08 11:59:38
Header: : ["Content-Type: application\/json","Authorization: Bearer 7855b000-f840-4a1e-aac1-cfc545382905"]
2021-02-08 11:59:38
Request: : {"email_address":"webgobe@gmail.com","first_name":"Denes","last_name":" Szekely","list_memberships":["fc3464f2-9a6e-11ea-9a0f-d4ae52844390"]}
2021-02-08 11:59:38
Response: : {"error_key":"unauthorized","error_message":"Unauthorized"}
The Header and the body in the above log entry are JSON encoded for readability. My problem is that I am getting this Unauthorized error. I even tried to test my code on the link found on dev portal, and that worked. I am clueless now, and any help is greatly appreciated!