-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetinfos.php
52 lines (40 loc) · 1.51 KB
/
getinfos.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
mb_internal_encoding("UTF-8");
$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
$json = file_get_contents(
"https://maps.googleapis.com/maps/api/place/radarsearch/json?location=-22.8893559,-47.0799138&radius=50000&types=bar&key=AIzaSyD5oEahVob9PzIfthabvAyN7VP9e7k-ByA",
false,
$context
);
$result = json_decode($json, true);
$bares = $result['results'];
$my_connect = mysql_connect("localhost","root","");
if (!$my_connect) { die('Error connecting to the database: ' . mysql_error()); }
mysql_select_db("black_onion", $my_connect);
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
$result = mysql_query('SELECT * WHERE 1=1');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
foreach ($bares as $bar) {
mysql_query("INSERT INTO tbgoogle (nome, place_id, lat, lng, rua, type) VALUES (
'" . $bar['name'] . "',
'" . $bar['place_id'] . "',
'" . $bar['geometry']['location']['lat'] . "',
'" . $bar['geometry']['location']['lng'] . "',
'" . $bar['vicinity'] . "',
'bar')");
}
/*foreach ($bares as $bar) {
mysql_query("INSERT INTO tbgoogle (place_id, lat, lng, type) VALUES (
'" . $bar['place_id'] . "',
'" . $bar['geometry']['location']['lat'] . "',
'" . $bar['geometry']['location']['lng'] . "',
'bar')");
}*/
mysql_close($my_connect);
// NAME PLACE_ID LAT LNG VICINITY
?>