I have my desktop development machine and my server. Both sit on the local network behind the same firewall.
I got Server Flow oAuth for v3 of the API working great on my desktop machine. I can get the token and refresh token, I've got all of the API calls working. Perfect. I got the initial set of token/refresh by pasting
Into my chrome browser on the desktop machine. Was presented with the login screen and then got back the "code" and then used with a cURL call in PHP to get the token/refresh. Worked great.
I went to use that same token on the server and the calls all failed. For example, I tried to get the Contact information using a specific contact_id. It failed and the first few lines of the cURL meta data is:
[url] => https://api.cc.email/v3/contacts/<contact_id>?include=custom_fields,list_memberships,phone_numbers,street_addresses [content_type] => [http_code] => 0
The http_code = 0.
I thought perhaps there was some sort of IP lock on the access_token. My desktop looks to the outside world as 126.96.36.199 while the server looks like 188.8.131.52. I tried using the *exact* same oAuth scheme that worked fine on my desktop on the server... Logged into the server, opened up Chrome, used the above https://api.cc.email/v3/idfed... URL, logged into the Constant Contact account when prompted, got back the https://localhost/?code=... However, when I tried to use that code in the cURL calls to https://idfed.constantcontact.com/as/token.oauth2... It didn't work and the cURL meta data said http_code = 0.
Any ideas appreciated...
Solved! Go to Solution.
Thank you for reaching out to Constant Contact's API Developer Support.
Unfortunately that error code by itself doesn't give a whole lot to go on. I can tell you that access tokens are not IP locked. I'd be interested to see what the specific cURL error is. Would you be able to add something like this before closing cURL?:
Tier II API Support Engineer
Good call. I woke up this morning thinking it was either TLS or CA certs...
The curl_error was SSL certificate problem: unable to get local issuer certificate
Sure enough, my desktop php.ini had curl.cainfo set to a very recent CA cert, while the server did not.
Everything working now.
(It's been a while since I was working with cURL and forgot about curl_error - I'll be adding that to the PHP class I've made for all the v3 Constant Contact stuff - thanks!)