forked from edouardkombo/hashtager
/
instagramScript.php
35 lines (28 loc) · 1.11 KB
/
instagramScript.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
<?php
// Get class for Instagram
// More examples here: https://github.com/cosenary/Instagram-PHP-API
require_once 'lib/instagram.class.php';
// Initialize class with client_id
// Register at http://instagram.com/developer/ and replace client_id with your own
$instagram = new Instagram(array(
'apiKey' => '6ffb1036a193401ca901270833b0b905',
'apiSecret' => 'c6c9139856ab474ba1c8d74fe97b7b10',
'apiCallback' => 'http://localhost'
));
// Set keyword for #hashtag
$tag = 'kisschoice';
// Get latest photos according to #hashtag keyword
$media = $instagram->getTagMedia($tag);
// Set number of photos to show
$limit = 5;
// Set height and width for photos
$size = '100';
echo json_encode($media->data);
/*
// Show results
// Using for loop will cause error if there are less photos than the limit
foreach(array_slice($media->data, 0, $limit) as $data)
{
// Show photo
echo '<p><img src="'.$data->images->thumbnail->url.'" height="'.$size.'" width="'.$size.'" alt="SOME TEXT HERE"></p>';
}*/