zaus / forms-3rdparty-integration

Wordpress Plugin - Forms 3rdparty Integration - a plugin to help integrate 3rdparty services with common WP Forms plugins like Contact Form 7 and Gravity Forms
http://wordpress.org/plugins/forms-3rdparty-integration/
47 stars 14 forks source link

'physical request failure' is thrown for 201 HTTP response code #49

Closed ezrafree closed 8 years ago

ezrafree commented 8 years ago

Hello,

We are using the forms-3rdparty-integration plugin with CF7 to map input names out to match what our CRM requires. Today we were made aware that an error was suddenly being triggered. Upon further investigation we came to realize that none of our code has changed in any way (we track changes through Git), so we continued investigating. Long story short, we eventually realized that the response returns a "201" HTTP response code. The following line of the forms-3rdparty-integration plugin throws the 'physical request failure' any time the response code is not equal to 200:

https://github.com/zaus/forms-3rdparty-integration/blob/master/forms-3rdparty-integration.php#L520

I was able to resolve the issue by modifying the plugin. First I created an array of (in my opinion) acceptable HTTP response codes:

$acc_resp_codes = array(
    '200',
    '201',
    '202'
);

Then I changed the above-mentioned line 520 to read:

elseif(!$response || !isset($response['response']) || !isset($response['response']['code']) || !in_array($response['response']['code'], $acc_resp_codes)) {

I'm posting this here in case anyone else out there runs into the same issue, and also to see what the plugin author(s) think of adding this in to the plugin. Let me know if there are any plans to include this in a future release or not, or if there are any other issues or concerns to consider.

zaus commented 8 years ago

Is good point; someone else mentioned this a while ago and I forgot about it.

Technically any of the 2xx codes should be considered "successful", and 3xx redirects should probably be too.

zaus commented 8 years ago

As an aside, kinda surprised your string array worked as I thought the response code was a number, but I might be thinking in C# and PHP is just more relaxed when comparing...

zaus commented 8 years ago

Please let me know if the fix doesn't work, or screws up what you needed.