I am using MAMP Pro 1.9.4 on Mac OSX
In phpinfo()
I see curl is enabled
cURL support enabled
cURL Information 7.20.0
Age 3
Features
If you are behind a proxy, you could try adding CURLOPT_PROXY
, for example (assuming your proxy is on 192.168.1.2 port 3128):
$ch = curl_init($geocodeURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, "192.168.1.2:3128");
$result = curl_exec($ch);
Hope this helps.
Do you actually have the curl
binary installed? You can have the curl
library installed with PHP without actually having the curl
binary on your system. Drop to a shell prompt and type curl
. (If it's standard on OSX then please forgive my ignorance - I'm not a Mac guy)
It's not about proxy, it's about how to use googleapis.
Add CURLOPT_SSL_ on
your code and set them into false
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
It's probably a firewall issue. Curl by default tries to use port 1080, which is probably not open on your localhost / router / ISP.
In MAMP, if you are getting errors when connecting to HTTPS hosts, just set this option:
curl_setopt($ch, CURLOPT_SSLVERSION,3);
The equivalent by command line is:
curl -k -ssl3 https://www.your-secure-host.com
You may need to set the SSL version and the matching Cipher for $ch
:
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
For the exact parameters you can pass to CURLOPT_SSLVERSION
see:
http://php.net/manual/en/function.curl-setopt.php
Also the following can display errors related to SSL versions being used to help find exact version conflict you have:
$error = curl_error($ch);
echo $error;
More on this command: http://php.net/manual/en/ref.curl.php