Skip to content

Instantly share code, notes, and snippets.

@bmcbride
Last active August 29, 2015 14:01
Show Gist options
  • Save bmcbride/95265ac472b7ce342aaf to your computer and use it in GitHub Desktop.
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.
<?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