Last active
August 29, 2015 14:01
-
-
Save bmcbride/95265ac472b7ce342aaf to your computer and use it in GitHub Desktop.
A simple script for viewing a contact page of photos, based on a column of comma delimited photo ID's as fetched from Fulcrum. Simply prepend 'http://someurl.com/fulcrum-photo-viewer.php?photos=' to your list of photo ID's.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fulcrum_api_key = 'your-fulcrum-api-key-goes-here'; | |
if (!isset($_GET['photos']) && !isset($_GET['photo'])){ | |
print 'photo or photos parameter required!'; | |
} | |
if (isset($_GET['photos'])) { | |
$photos = explode(',', $_GET['photos']); | |
foreach ($photos as $key => $value) { | |
$context = [ | |
'http' => [ | |
'method' => 'GET', | |
'header' => 'X-ApiToken: ' . $fulcrum_api_key | |
] | |
]; | |
$context = stream_context_create($context); | |
$photo = file_get_contents('https://api.fulcrumapp.com/api/v2/photos/' . $value . '/thumbnail.jpg', false, $context); | |
print '<center><p><a href=\'?photo=' . $value . '\' target=\'_blank\'><img title=\'View Full Size\' src=\'data:image/jpeg;base64,' . base64_encode($photo) . '\'></a></p></center>'; | |
} | |
} | |
if (isset($_GET['photo'])) { | |
$context = [ | |
'http' => [ | |
'method' => 'GET', | |
'header' => 'X-ApiToken: ' . $fulcrum_api_key | |
] | |
]; | |
$context = stream_context_create($context); | |
$photo = file_get_contents('https://api.fulcrumapp.com/api/v2/photos/' . $_GET['photo'] . '.jpg', false, $context); | |
header('Content-Type: image/jpeg'); | |
print $photo; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment