This is a plugin for Kirby that loads images from the Instagram API.
-
Put the
instagram.phpfile in yoursite/pluginsfolder. If this folder doesn't exist yet, create it. -
In order to interact with the Instagram API, you need to obtain an access token for yourself.
-
Visit http://instagram.com/developer/clients/manage/ and register an application.
-
Set the OAuth redirect_uri to the main URL (i.e. http://yourdomain.com) of your website.
-
Copy the Client-ID of the newly created app.
-
Visit:
https://instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=http://yourdomain.com&response_type=token
…in your browser, but replace CLIENT-ID with your client-id and YOURDOMAIN.COM with the OAuth redirect_uri you've entered while registering your app.
-
The browser will redirect you to your own website and in the address bar you will find your access token like this:
http://yourdomain.com/#access_token=xxxxx.xxxxx.xxxxxxxxxxx -
Copy the access token (everything after =) and save it somewhere.
-
Implement the plugin into your template.
To update, just replace the old instagram.php file in site/plugins, with the new one.
<?php
// Load an instagram object using your access_token (see installation)
// containing 10 shots.
// Note: Replace XXX… with your access_token
$instagram = instagram('XXX.XXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXX', 10);
$images = $instagram->images();
foreach ($images as $image): ?>
<div class="instagram-photo">
<a href="<?php echo $image->link ?>"><img src="<?php echo $image->url ?>" /></a>
<div class="location">
<span>
<?php echo $image->location ?> (<?php echo $image->latitude ?>, <?php echo $image->longitude ?>)
</span>
</div>
</div>
<?php endforeach ?>
Advanced Users: See the source for further options.
$image->linkThe link to the image$image->commentsThe number of comments$image->likesThe number of likes$image->createdThe timestamp when the image was created$image->thumbThe url of the thumbnail of the image$image->urlThe url of the full-sized image$image->image_lowresThe url to a low-res version of the image$image->filterThe filter that was used$image->locationThe location name$image->latitudeThe latitude of the location$image->longitudeThe longitude of the location$image->tagsAn array of tags of the image
$user->usernameThe username of the user$user->full_nameThe full name of the user$user->pictureThe url to the avatar of the user
Your web server must have support for cURL (installation instructions).
Copyright 2012, Simon Albrecht http://albrecht.me/. If you use this plugin, feel free to ping me @s_albrecht.