PHP Export Contacts Questions

Occasional Participant

PHP Export Contacts Questions

 

I believe I have successfully completed an Export Activity and I want to download the CSV - Doc says:

 

'Once the activity has completed processing, the status includes a file_name property with the URI pointing to the exported file. Make a GET call to the URI to retrieve the file.'

 

I'm not sure I totally understood above statement - I ran a status check and found the following:

 

class Ctct\Components\Activities\Activity#26 (8) {
public $id =>
string(19) "a07e8x4jxs1hrikdjpo"
public $type =>
string(15) "EXPORT_CONTACTS"
public $status =>
string(8) "COMPLETE"
public $start_date =>
string(24) "2014-02-11T02:42:37.266Z"
public $finish_date =>
string(24) "2014-02-11T02:42:37.545Z"
public $created_date =>
string(24) "2014-02-11T02:42:08.268Z"
public $error_count =>
int(0)
public $contact_count =>
int(2)
}

 

I don't see that the 'status includes a file_name property'. So I tried moving on to the second part of the doc which I believe says to retrieve the doc using:

 

GET https://api.constantcontact.com/v2/activities/exportfiles/<activity_id>.<file_extension>

 

so I tried the following:

 

https://api.constantcontact.com/v2/activities/exportfiles/a07e8x4jxs1hrikdjpo.csv

 

I got the following response:

 

[{
"error_key":"mashery.not.authorized.inactive",
"error_message":"The Mashery account associated with this request is not active, or an invalid API key was used."
}]

 

I also tried various things like adding my token to the GET headers and adding my api key to the url but to no avail

 

Any thoughts?

 

Thanks!

 

3 REPLIES 3
Moderator

I need to look at the return again to see if the docs are wrong for the 1st part of your question. For the 2nd part, just add the api_key query parameter to the GET call you made to retrieve the file,

https://api.constantcontact.com/v2/activities/exportfiles/a07e8x4jxs1hrikdjpo.csv?api_key=<your_api_key>

 

Let me check the docs and the return, I'll get back on that shortly.

 

Thanks,

Rich Marcucella

Sr. Technical Writer, Content Developer

Web Services Team.

Rich Marcucella
Sr. Technical Writer, Content Developer
Web Services Team
http://developer.constantcontact.com
Occasional Participant

 

Thanks for the response!  Success - I had tried the key and the token but not both together - so using query params, the following worked:

 

https://api.constantcontact.com/v2/activities/exportfiles/<activity_id>.<file_extension>?api_key=<my_api_key>&access_token=<my_access_token>

Rob, glad it worked for you. I've created a bug to make the documentation more specific about what's required to access the exported file, and to clarify some of the other info there about the activity status, etc. 

 

Thanks for posting, it will definitely help make the docs and portal better for you guys.

 

Regards,

Rich M

Rich Marcucella
Sr. Technical Writer, Content Developer
Web Services Team
http://developer.constantcontact.com
Developer Portal

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

Visit Page