[CODE] function to get google place recommandations


function fetch_google_venue_recommandation($place_name,$long,$lat){
 global $logger;
 $url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=" . $place_name . "&sensor=true&location=".$long.",".$lat. "&key=" . GOOGLE_APP_KEY;
 $places = null;
 $logger->debug($url);
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 $data = curl_exec($ch); // Yelp response
 curl_close($ch);
 $response = json_decode($data);
 return $response;
 }

Advertisements

A short and easy example of CURL

<code>

$filename=”https://graph.facebook.com/oauth/access_token?client_id=&#8221;.FB_APP_ID.”&redirect_uri=http://”.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI].”&client_secret=”.FB_APP_SECRET.”&code=”.$code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $filename);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//$output = file_get_contents(urlencode($filename),true);
$output = curl_exec($ch);
var_dump(curl_error($ch));
exit();

</code>

Using cURL in PHP to access HTTPS (SSL/TLS) protected sites » unitstep.net

it worked for me. 🙂

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

via Using cURL in PHP to access HTTPS (SSL/TLS) protected sites » unitstep.net.

A simple post data submission in PHP with cURL

Here is the code i made :

function log_in($name, $password) {
        extract($_POST);
        $curl_handle = curl_init(“http://localhost/projects/db_les/index.php?c=login&v=loginOk&#8221;);

        $post_array = array(‘userName’ => “$name”, ‘password’ => “$password”);
        $post_string = “”;
        foreach ($post_array as $key => $value) {
            $post_string .= $key . ‘=’ . $value . ‘&’;
        }
        rtrim($post_string, ‘&’);
        $options = array(
            CURLOPT_RETURNTRANSFER => true, // return web page
            CURLOPT_HEADER => false, // don’t return headers
            CURLOPT_FOLLOWLOCATION => true, // follow redirects
            CURLOPT_ENCODING => “”, // handle all encodings
            CURLOPT_USERAGENT => “spider”, // who am i
            CURLOPT_AUTOREFERER => true, // set referer on redirect
            CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
            CURLOPT_TIMEOUT => 120, // timeout on response
            CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
            CURLOPT_COOKIEJAR => $this->tmp_fname,
            CURLOPT_POST => count($post_array),
            CURLOPT_POSTFIELDS => $post_string,
            CURLINFO_HEADER_OUT => true,
        );

        curl_setopt_array($curl_handle, $options);
        $output = curl_exec($curl_handle);
        
        curl_close($curl_handle);
    }

 

Enable curl with XAMPP on Windows XP

Here is a good post discussing its solution:-

http://www.tildemark.com/programming/php/enable-curl-with-xampp-on-windows-xp.html

Hope you will like it.