From 660b2ddcc258cb5350fa351bd4e51d5b4723f495 Mon Sep 17 00:00:00 2001 From: Kevin Wenger Date: Thu, 11 Jun 2015 17:38:57 +0200 Subject: [PATCH 1/2] Remove SSL Verify on Windows Avoid error CURL Error: SSL certificate problem: unable to get local issuer certificate on windows whitout ssl --- src/GooglePlacesClient.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/GooglePlacesClient.php b/src/GooglePlacesClient.php index 9a7ca30..efe2497 100644 --- a/src/GooglePlacesClient.php +++ b/src/GooglePlacesClient.php @@ -17,6 +17,11 @@ class GooglePlacesClient curl_setopt_array($curl, $options); + // Add certificate for Windows + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); + } + $response = curl_exec($curl); if ($error = curl_error($curl)) From 1eab9c4f5caa52afa45369bae3aaafcb988f6765 Mon Sep 17 00:00:00 2001 From: Kevin Wenger Date: Fri, 12 Jun 2015 10:45:55 +0200 Subject: [PATCH 2/2] Improve coding conventions --- src/GooglePlacesClient.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/GooglePlacesClient.php b/src/GooglePlacesClient.php index efe2497..e897abe 100644 --- a/src/GooglePlacesClient.php +++ b/src/GooglePlacesClient.php @@ -8,20 +8,22 @@ class GooglePlacesClient { $curl = curl_init(); + $ssl_verifypeer = true; + // Remove ssl certificate verification for Windows + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') + { + $ssl_verifypeer = false; + } + $options = array( CURLOPT_URL => $url, CURLOPT_HEADER => false, - CURLOPT_SSL_VERIFYPEER => true, + CURLOPT_SSL_VERIFYPEER => $ssl_verifypeer, CURLOPT_RETURNTRANSFER => true, ); curl_setopt_array($curl, $options); - // Add certificate for Windows - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); - } - $response = curl_exec($curl); if ($error = curl_error($curl))