Getting list of Lists via cURL

Highlighted
Occasional Contributor

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
Highlighted
Moderator

Re: Getting list of Lists via cURL

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

Register for our "Making Sense of Online Marketing for Retail" Webinar

Join us on Thursday, August 13th at 2pm ET for a free webinar where we'll discuss how to incorporate online marketing into your retail store.

Read More
Featured