Search the Community
Showing results for tags 'Google Places Curl'.
-
Hello! I am a new user of the Stevie server. I am setting up a script which has worked on other server (and still works elsewhere). The script attempts to access the Google Places API by sending a CURL request. However, most of the time the PHP script will error out on the Stevie server. Occasionally it will work but not typically. This script works 100% on a different server that I am migrating from. Here is the relevant code: $placeName = 'XXX'; $lat = '37'; $lon = '-122'; $radius = '10000'; //Meters $dataType = 'json'; //json or xml $url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/'; $url .= $dataType; $url .= '?key='.$Google_Maps_API_Key; //Stored in envoirnment.php $url .= '&location='.$lat.','.$lon; $url .= '&radius='.$radius; $url .= '&name='.$placeName; $curl = curl_init($url); curl_setopt($curl, CURLINFO_HEADER_OUT, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_DNS_USE_GLOBAL_CACHE, false ); curl_setopt($curl, CURLOPT_DNS_CACHE_TIMEOUT, 2 ); echo curl_exec($curl); As I said, once in a while the script will execute and the JSON will be returned. Most of the time I get an error. If I print the CURL error I get this: 7: Failed to connect to 2607:f8b0:400e:c03::5f: Network is unreachable Other times, if I am not error checking in my code, the script will simply timeout and give HelioHosts Internal Server Error 500 page If I print $url before the CURL and copy/paste the url into my browser, I get the JSON form google fine so I know it is not a malformed URL. Could there by a network issue btwn Helio Host and Google? Thank you for taking the time to read my post. Here is the script: http://vitaecafe.tk/vitae/actions.php?a=4