-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
29 lines (23 loc) · 864 Bytes
/
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
<?php
require_once(__DIR__.'/users/users.php');
// get user if logged in or require user to login
$user = User::require_login();
$creds = $user->getUserCredentials('instagram');
$result = $creds->makeOAuth2Request(
'https://api.instagram.com/v1/users/self/media/recent/',
'GET'
);
// start with global template data needed for Startup API menus and stuff
$template_info = StartupAPI::getTemplateInfo();
$template_info['name'] = $user->getName();
$feed = json_decode(utf8_encode($result), true);
if ($feed['meta']['code'] == 200) {
foreach ($feed['data'] as $image) {
$template_info['images'][] = array(
'url' => $image['images']['thumbnail']['url'],
'caption' => $image['caption']['text']
);
}
}
StartupAPI::$template->getLoader()->addPath(__DIR__ . '/templates', 'app');
StartupAPI::$template->display('@app/index.html.twig', $template_info);