The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

PHP API failing on one server but not another

SOLVED
Go to solution
Highlighted
Occasional Participant

PHP API failing on one server but not another

I'm trying to figure out what the possible difference is, but it is really, really strange.  

 

I've identified the exact failure point.  It occurs when curl_exec($curl) is called in the RestClient::HttpRequest class.  

 

A try catch block does not work.  I get NO error.  Just a blank page.  Nothing in an error log.  Calling curl via the command line, everything is kosher with curl, though.  

 

This works on my development box, but not in production (of course)  :(  LAMP stack, Ubutnu in AWS.  

 

Just before I was going to send this, I tested a non-ssl link and it seems to work.  So, I've also identified that it has to do with https.  Curl is installed with SSL support, I've attached my php_info output for it. (nevermind, it won't post with an image attached)  :(

 

What would be a great place to start looking?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Occasional Participant

Re: PHP API failing on one server but not another

So I ended up rebuilding my webserver from the ground up with a newer OS (ubuntu 12.04 LTS) and the newest web server we use (Zend Server) and the curl requests are working properly.  

 

Maybe someone else may find this some day.  

View solution in original post

4 REPLIES 4
Highlighted
Employee

Re: PHP API failing on one server but not another

Hi,

 

It sounds like the request isn't even making it out, or perhaps the production server has security set up that won't allow our response to the https request through to you.  Are you using verify peer, and can you see which version of PHP you have on the production box?  Can you use a restclient to make a call in the production environment and see if you see a response back?

 

I use a chrome restclient plugin that I'm very happy with; beyond the URL, you would need just two headers to make a GET call to us.  Sample uri (be sure to include your API Key):

 

https://api.constantcontact.com/v2/contacts?api_key=api_key_value

 

Headers:

 

Authorization: Bearer access_token_value
Content-type: application/json

 

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: PHP API failing on one server but not another

I'm able to connect via command line just fine: 

 

curl -H "Authorization: Bearer ***" -H "Content-type: application/json" https://api.constantcontact.com/v2/contacts?api_key=***&email=test@test.com

 

I'm running PHP 5.3.14

Highlighted
Employee

Re: PHP API failing on one server but not another

Hi,

 

Obviously it's hard to troubleshoot without errors, but given that this is only an issue with https requests, see this page for some possible causes and solutions to certificate issues.

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: PHP API failing on one server but not another

So I ended up rebuilding my webserver from the ground up with a newer OS (ubuntu 12.04 LTS) and the newest web server we use (Zend Server) and the curl requests are working properly.  

 

Maybe someone else may find this some day.  

View solution in original post

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured