function rip_flickr_data($record) { $lics = flickr_get_licenses(); // echo '<pre>'; print_r($lics); die(); $title = $record['title']; $license = $lics[$record['license']]; // echo '<pre>';print_r($license); die(); $description = ''; $sizes = flickr_request('flickr.photos.getSizes', array('photo_id' => $record['id'])); $sizes = $sizes['sizes']; $thumbs = array(); // w:h => array( file, file, file) $largest = array(0, '', 0, 0); $smallest = array(3000 * 3000, '', 3000, 3000); // Ok, hacky, sosumi foreach ($sizes['size'] as $thumb) { if ($thumb['label'] == 'Square') { continue; } // These are a little smaller than default if (!isset($thumbs["{$thumb['width']}x{$thumb['height']}"])) { $thumbs["{$thumb['width']}x{$thumb['height']}"] = array(); if ($thumb['width'] * $thumb['height'] > $largest[0]) { $largest = array($thumb['width'] * $thumb['height'], $thumb['width'] . 'x' . $thumb['height'], $thumb['width'], $thumb['height']); } if ($thumb['width'] * $thumb['height'] < $smallest[0]) { $smallest = array($thumb['width'] * $thumb['height'], $thumb['width'] . 'x' . $thumb['height'], $thumb['width'], $thumb['height']); } } $thumbs["{$thumb['width']}x{$thumb['height']}"][] = $thumb; } // Find the main image link $mainImage = $thumbs[$largest[1]]; $mainImage = array_pop($mainImage); // Find the thumb image link $thumbImage = $thumbs[$smallest[1]]; $thumbImage = array_pop($thumbImage); // Final image to pass to manager (use query param to record the embed url) $combinedImage = $mainImage['source'] . '?x-flickr-photo=' . rawurlencode($record['id']) . '&x-lic=' . rawurlencode($license['x-id']) . '&x-uid=' . rawurlencode($record['owner']) . '&x-by=' . rawurlencode($record['ownername']) . '&x-tn=' . rawurlencode($thumbImage['source']); return array('title' => $title, 'description' => $description, 'dimensions' => "{$mainImage['width']}x{$mainImage['height']}", 'license' => $license, 'mainImage' => $mainImage['source'], 'thumbImage' => $thumbImage['source'], 'combinedImage' => $combinedImage, 'smallest' => $smallest, 'largest' => $largest, 'thumbs' => $thumbs); }
function flickr_get_user_id($NameOrEmail) { if (preg_match('/@/', $NameOrEmail)) { $d = flickr_request('flickr.people.findByEmail', array('find_email' => $NameOrEmail)); if ($d) { return $d['user']['id']; } } else { $d = flickr_request('flickr.people.findByUsername', array('username' => $NameOrEmail)); if ($d) { return $d['user']['id']; } } }