We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Getting list of Lists via cURL

ShelleyM2
Occasional Participant

Getting list of Lists via cURL

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
Moderator

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
Developer Portal

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

Visit Page