-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstagram.php
32 lines (27 loc) · 1011 Bytes
/
instagram.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
<?php
// Instagram
//https://instagram.com/oauth/authorize/?client_id=[CLIENT_ID_HERE]&redirect_uri=http://localhost&response_type=token
require 'config.php';
require 'Instagram-PHP-API/src/InstagramException.php';
require 'Instagram-PHP-API/src/Instagram.php';
use MetzWeb\Instagram\Instagram;
$instagram = new Instagram($config['instagram']['client_id']);
$instagram->setAccessToken($config['instagram']['access_token']);
$posts = array();
try {
$response = $instagram->getUserMedia(181846997,10);
if($response->meta->code != 400){
foreach ($response->data as $project) {
// Project data
$post['date'] = strtotime($project->created_time);
$post['title'] = $project->caption->text;
$post['image'] = $project->images->standard_resolution->url;
$post['category'] = implode(", ", $project->tags);
$post['url'] = $project->link;
$posts[] = $post;
}
}
} catch (Exception $e) {
print $e->getMessage();
}
return $posts;