I am trying to implement an app in PHP to update a contact's list membership. Post and Get functions all work fine on localhost and remote for getting contact details and adding a new contact. However, the addSubscriber function returns false if the contact already exist in the master list. So I also need to allow existing subscribers to be added to a new list if they signup for a promotion.
I am using the subscriberExists function to determin if a contact already exists and what lists they are already on. Then using the editSubscriber function to update the user's list membership and Put the edited contact details back up to CC. Everything works fine in RESTClient and from my PHP app on localhost but refuses to work on the remote testing server. The remote server does not have remote debugging but I have determined that the doServerCall function appears to generate a well formed Put response in $emessage but as soon as the function triggers return, PHP dies. I cannot get any error messages or any return of any kind in the calling function (editSubscriber) and the page load stops dead.
Bruce G. Mills
Well, I finally fount a fix for this buried in another thread posted last month. The fix in your words:
We have noticed that depending on your server configuration, the PUT statement may hang and eventually time-out. This is most likely due to an issue with your cURL instillation and can most likely be resolved by changing the cURL method option as seen below:
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
This fix worked in my app. My question is, why aren't these issues documented and corrected in your API. It is irresponsible to publish a defective API to unsuspecting customers and not document its shortcoming. There is nothing endearing about having to stumble through your code and repeat the same mistakes made by dozens of people before you. Then to have to go on a treasure hunt to find out why it doesn't work. You likely lose a lot of customers over these shody docs!
Bruce G. Mills
Sorry for the problems you ran into Bruce. The sample code uses the PHP best practices way for sending curl PUT requests, which is to use the predefined CurlOpts for sending requests. Some developers have found that their servers are not configured properly to allow these requests and the method you used to send the request is a workaround for these configuration issues. I can certainly understand how this could be frustrating from a developer standpoint.
We will look into possibly adding some additional comments to the sample code which will reflect this workaround in case future developers run into it. PHP support has proven to be challenging as there are many different server configuration options and OS versions running PHP. Whenever we find something like this that can be fixed with a change, we do document it in a forum sticky thread. I will make sure to pass this documentation feedback on to our development team though for future update consideration.
View API documentation, code samples, get your API key.Visit Page
We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...Read More