How can I get a list of all unsubscribed contacts from the previous day using the API?
I am using the php SDK.
I want to run a daily cron job that pulls the full list of unsubscribed contacts from the previous day.
Any help is appreciated!
The best way to solve this problem is to combine two of the query parameters available on the ContactService.getContacts method. Here's what the usage would look like:
$results = $contactServiceObject.getContacts($accessToken, array("status" => "OPTOUT", "modified_since" => "2016-04-26T20:10:06Z"));
the parameters that we are passing in are the desired status (OPTOUT) and an additional parameter that filters it to only contacts that have been modified since the given date. It is theoretically possible that there could be other modifications (such as a name change) to an opted out contact, but they would be very uncommon and should not hurt your process as it will still only report on opted out contacts. This will catch any contacts who have recently opted out, as any changes to list memberships will update the modified date of a contact.
Let me know if you have any questions!