function oa_createLocationFS($accessToken, $adresse, $nom_lieux) { global $wpdb; $randomnumber = rand(100000, 999999); $adresse = wp_strip_all_tags($adresse); // 1 . je construit une fonction pour récup' les coords function get_coords($a) { // je construit une URL avec l'adresse $map_url = 'http://maps.google.com/maps/api/geocode/json?address=' . urlencode($a) . '&sensor=false'; // je récupère ça $request = wp_remote_get($map_url); $json = wp_remote_retrieve_body($request); // si c'est vide, je kill... if (empty($json)) { return false; } // je parse et je choppe la latitude et la longitude $json = json_decode($json); $lat = $json->results[0]->geometry->location->lat; $long = $json->results[0]->geometry->location->lng; // je retourne les valeurs sous forme de tableau return compact('lat', 'long'); } // 2. je lance ma fonction, l'adresse en parametre $coords = get_coords($adresse); // 3. si j'ai récupéré des coordonnées, je sauvegarde if ($coords != '') { $latitude = $coords['lat']; $longitude = $coords['long']; } $ch_lieux = curl_init("https://api.openagenda.com/v1/locations"); //curl_setopt($ch_lieux, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch_lieux, CURLOPT_POST, true); curl_setopt($ch_lieux, CURLOPT_POSTFIELDS, array('access_token' => $accessToken, 'nonce' => $randomnumber, 'data' => json_encode(array('placename' => $nom_lieux, 'address' => $adresse, 'latitude' => $latitude, 'longitude' => $longitude)))); curl_setopt($ch_lieux, CURLOPT_RETURNTRANSFER, TRUE); $received_content = curl_exec($ch_lieux); if (curl_getinfo($ch_lieux, CURLINFO_HTTP_CODE) == 200) { $data2 = json_decode($received_content, true); $location_uid = $data2['uid']; } return $location_uid; }
$left = $x; $top = $y; $right = $x + 5; $bottom = $y - 5; return "coords=\"{$left},{$top},{$right},{$bottom}\""; } $width = 400; $height = 200; $test = 5; for ($x = 1; $x <= $width; $x += $test) { for ($y = 1; $y <= $height; $y += $test) { $chartX = $x; $chartY = $height - $y; ?> <area class="area" nohref <?php echo get_coords($chartX, $chartY); ?> onMouseover="ddrivetip('X:<?php echo $chartX; ?> ,Y:<?php echo $y; ?> ',70 ,'lightyellow')"; onMouseout="hideddrivetip()"/> <?php } } ?> </map> <div class="charttable"> <table>
<?php include 'multi_choice.php'; $data = explode(',', $_GET['data']); echo get_result(get_coords($data));
<?php include 'multi_choice.php'; header('Content-Type: image/jpeg'); $data = explode(',', $_GET['data']); show_image(get_coords($data));
echo "<h3>{$msg}</h3>\n\n"; html_tail(); exit; } } // --------------------------------------------------------------------------------------- // Get coordinates for east and west of 30W // --------------------------------------------------------------------------------------- if ($djia_e) { list($lat_e, $lon_e) = get_coords($get_date, $djia_e, $get_debug); } if ($djia_e) { list($lat_g, $lon_g) = get_global($get_date, $djia_e, $get_debug); } if ($djia_w) { list($lat_w, $lon_w) = get_coords($get_date, $djia_w, $get_debug); } // --------------------------------------------------------------------------------------- if ($get_debug) { echo "<p>"; if ($djia_e) { echo "\$lat_e = {$lat_e} \$lon_e = {$lon_e}"; } if ($djia_w) { echo "<br>\$lat_w = {$lat_w} \$lon_w = {$lon_w}<br><br>\$lat_g = {$lat_g} \$lon_g = {$lon_g}"; } echo "</p>\n\n"; } $day = date('D', strtotime($get_date)); // Get "Mon" or something similar from 2016-01-25 $day_nn = $day . " " . substr($get_date, 8);