-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
81 lines (64 loc) · 2.51 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
require 'vendor/autoload.php';
require 'InstagramService.php';
header("Content-Type: application/json");
$instagramService = new InstagramService;
$locationId = $_GET['location_id'] ?? '1027564636';
//$response = $instagramService->getLocationData($locationId)['native_location_data'];
$response = $instagramService->getBetano();///$instagramService->getLocations('1');
echo json_encode($response);
exit;
$data = [
'location' => [],
'ranked' => [],
'recent' => [],
];
if (isset($response['location_info'])) {
$data = [
'location' => $response['location_info'],
'ranked' => [],
'recent' => [],
];
foreach ($response['ranked']['sections'] as $section) {
foreach($section['layout_content']['medias'] as $media) {
$data['ranked'][] = [
'user' => $media['media']['user'],
'media' => $media['media']['image_versions2']['candidates'][0] ?? []
];
}
}
foreach ($response['recent']['sections'] as $section) {
foreach($section['layout_content']['medias'] as $media) {
$data['recent'][] = [
'user' => $media['media']['user'],
'media' => $media['media']['image_versions2']['candidates'][0] ?? []
];
}
}
// echo json_encode($data);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>InstagramService</title>
</head>
<body>
<?php foreach($data['ranked'] as $ranked):?>
<?php if (isset($ranked['media']['url'])):?>
<img width="300" src="data:image/jpg;base64,<?php echo base64_encode(file_get_contents($ranked['media']['url']));?>">
<h1>Nome: <?php echo $ranked['user']['full_name'];?>, <a target="_blank" href="https://instagram.com/<?php echo $ranked['user']['username'];?>"><?php echo $ranked['user']['username'];?></a></h1>
<hr>
<?php endif;?>
<?php endforeach;?>
<?php foreach($data['recent'] as $recent):?>
<?php if (isset($recent['media']['url'])):?>
<img width="300" src="data:image/jpg;base64,<?php echo base64_encode(file_get_contents($recent['media']['url']));?>">
<h1>Nome: <?php echo $recent['user']['full_name'];?>, <a target="_blank" href="https://instagram.com/<?php echo $recent['user']['username'];?>"><?php echo $recent['user']['username'];?></a></h1>
<hr>
<?php endif;?>
<?php endforeach;?>
</body>
</html>