API v3 always gives "Unauthenticated error" message

Participant

API v3 always gives "Unauthenticated error" message

My company has an Email Plus account on Contact Contact.
We need to use Constant Contact API v3. I have followed the steps given in this article (https://v3.developer.constantcontact.com/api_guide/getting_started.html?_ga=2.29322108.1308822313.16... ) to register my application. 
Now, inside my PHP project, when I use the API Key and Secret (Generated through the steps given in the above article), I always get the "Unauthenticated error". 
I have tried to make calls to API with api_key as a query parameter and passing the access token in the header and also making a call to API without api_key as a query parameter.

None of the above worked and gave me the same unauthenticated error. I am using the following code :
       $token = "";
        $apiKey = "";
        
        $ch = curl_init();
        $headers = array();
        $headers[] = "Authorization: Bearer {$token}";
        $headers[] = 'Content-Type: application/json';
        $headers[] = 'Cache-Control: no-cache';
        $headers[] = 'Accept: application/json';
    
        // set URL and other appropriate options
        //curl_setopt($ch, CURLOPT_URL, "https://api.cc.email/v3/contacts?include_count=false?api_key=$api_key");
        curl_setopt($ch, CURLOPT_URL, "https://api.cc.email/v3/contacts");
        curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
        //curl_setopt($ch,CURLOPT_POSTFIELDS, $json_data);
           
        $curl_response = curl_exec($ch); 
        curl_close($ch); 
Am I doing anything wrong? Also, this access token is what I generated after registering the app
in the "My Application" section. Secondly, we have an Email Plus account instead of Developer's, is that
a problem?
 
2. Is there any way, where using the template IDs or any other identifier for the templates,  can I use the Templates for the emails through API? and can send variables to the template for example the Username or their email address or maybe a customized message?
0 REPLIES 0
Developer Portal

View API documentation, code samples, get your API key.

Visit Page