} catch (exception $e) { $event_query_exception = $e; } // get the remote IP $ip = getenv('REMOTE_ADDR'); // find location posted by user if ($_POST) { // already URL encoded $location = $_POST['location']; // user friendly display name of user location if ($location != "") { $location = urlencode($location); $place_name = urldecode($location); // geocode try { $location_XML = yahoo_geo($_REQUEST['location']); $location = $location_XML['Latitude'] . "," . $location_XML['Longitude']; $location_latitude = $location_XML['Latitude']; $location_longitude = $location_XML['Longitude']; // get event number $event_index = $_POST['event_index']; if ($event_index > 0) { $conn = get_db_connection($db_user, $db_passwd, $db_name); $event_label = $event_index; $latitudes[$event_index] = $location_latitude; $longitudes[$event_index] = $location_longitude; $sql_result = save_vote($location_latitude, $location_longitude, $event_label); // $db_status_close = close_db_connection($conn); } else { $event_label = "";
<?php require_once './yahoo.php'; $request_add = $_GET['area']; $geo = yahoo_geo($request_add); // ぐるなびAPI // http://api.gnavi.co.jp/api/manual/restsearch/ /***************************************************************************************** * ぐるなびWebサービスのレストラン検索APIで緯度経度検索を実行しパースするプログラム * 注意:緯度、経度、範囲の値は固定で入れています。 * アクセスキーはユーザ登録時に発行されたキーを指定してください。 *****************************************************************************************/ //エンドポイントのURIとフォーマットパラメータを変数に入れる $uri = "http://api.gnavi.co.jp/RestSearchAPI/20150630/"; //APIアクセスキーを変数に入れる $acckey = '14c383d2e30f47f282bd9b688c62eb22'; //返却値のフォーマットを変数に入れる $format = "json"; //緯度・経度、範囲を変数に入れる //緯度経度は日本測地系で日比谷シャンテのもの。範囲はrange=1で300m以内を指定している。 $lat = $geo['latitude']; $lon = $geo['longitude']; $range = 1; $hit_per_page = 100; //URL組み立て $url = sprintf("%s%s%s%s%s%s%s%s%s%s%s%s%s", $uri, "?format=", $format, "&keyid=", $acckey, "&latitude=", $lat, "&longitude=", $lon, "&range=", $range, "&hit_per_page=", $hit_per_page); //API実行 $json = file_get_contents($url); //取得した結果をオブジェクト化 $obj = json_decode($json); //echo '$obj'.'<br>';