-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathindex.php
executable file
·54 lines (51 loc) · 1.57 KB
/
index.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
53
54
<?php
if (!empty($_GET['location'])) {
/**
* Here we build the url we'll be using to access the google maps api
*/
$maps_url = 'https://' .
'maps.googleapis.com/' .
'maps/api/geocode/json' .
'?address=' . urlencode($_GET['location']);
$maps_json = file_get_contents($maps_url);
$maps_array = json_decode($maps_json, true);
$lat = $maps_array['results'][0]['geometry']['location']['lat'];
$lng = $maps_array['results'][0]['geometry']['location']['lng'];
/**
* Time to make our Instagram api request. We'll build the url using the
* coordinate values returned by the google maps api
*/
$url = 'https://' .
'api.instagram.com/v1/media/search' .
'?lat=' . $lat .
'&lng=' . $lng .
'&client_id=CLIENT-ID'; //replace "CLIENT-ID"
$json = file_get_contents($url);
$array = json_decode($json, true);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>geogram</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<form action="" method="get">
<input type="text" name="location"/>
<button type="submit">Submit</button>
</form>
<br/>
<div id="results" data-url="<?php if (!empty($url)) echo $url ?>">
<?php
if (!empty($array)) {
foreach ($array['data'] as $key => $item) {
echo '<img id="' . $item['id'] . '" src="' . $item['images']['low_resolution']['url'] . '" alt=""/><br/>';
}
}
?>
</div>
</body>
</html>