Wednesday 11 June 2014

Syncing your Instagram photos to CartoDB

I really want to show photos on my expedition map. Instead of creating my own photo service, I want to use a service that already support geotagged photos, Instagram. To get more control, I'm syncing the metadata for my photos and videos to my CartoDB-account using the Instagram API.

CartoDB-map showing Instagram photos.

Please read the API Terms of Use before you start doing this. You shall not "cache or store any User Content other than for reasonable periods in order to provide the service you are providing to Instagram users". Here I'm only syncing textual data from my own user on Instagram. You can also show your Instagram photos on a map, using the Instagram API directly, as I will show in my next blog post. 

I've created a PHP cron job, instagram2cartodb.php, that will sync my photos and videos to CartoDB:

The script will read the latest images from an Instagram user using an access token. It also reads the latest timestamp from the CartoDB-table, to check which images are newer. I'm only storing geotagged images and videos, as I want to show these on a map.

I've created a CartoDB map of my photos from Foldøy island using this short tutorial on info-windows with image support:  

In the next blog post, we'll put our Instagram photos on a custom Leaflet map.

1 comment:

Mark! said...

Can you give an example of the config.php file? I can't seem to figure out the instagram or cartodb config values.