Getting list of Lists via cURL

ShelleyM2
Rookie
0 Votes

I am having problems figuring out how to get a list of Lists via cURL.

 

I am able test the API with my APIKey and Token on site https://constantcontact.mashery.com/io-docs, but can't replicate it in my own code:

>>

$url = "https://api.constantcontact.com/v2/lists?&api_key=". $apiKey;
echo "Getting mailing list IDs ... ";
$header[] = "Authorization: Bearer $token";
$header[] = 'Content-Type: application/json';

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
echo curl_exec($ch);
$response = json_decode(curl_exec($ch));

print_r ($response);

<<

The response I am getting is:

[{"error_key":"query.param.invalid","error_message":"The query parameter is not supported."}]Array ( [0] => stdClass Object ( [error_key] => query.param.invalid [error_message] => The query parameter is not supported. ) )

 

Any idea what I am doing wrong, or am missing?


Adam

 

1 REPLY 1
Jimmy_D
Employee
0 Votes

Hello @ShelleyM2 ,

 

Thank you for reaching out to Constant Contact's API Support.

 

Looks to be a syntax error. You have both a ? and & before api_key. Since this is the first (and only) query parameter you just need the ?.


Regards,
Jimmy D.
Tier II API Support Engineer
Resources
Developer Portal

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

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up