entry as $recent_photo) { $thumb_url = current($recent_photo->id); $album_link = current($recent_photo->link['href']); if (preg_match('/\/photos\/([0-9]+)\-.*?\.jpg$/', $thumb_url, $matches)) { $sm_photo_id = $matches[1]; } if (preg_match('/\/gallery\/([0-9]+)#/', $album_link, $matches)) { $sm_album_id = $matches[1]; } if (!array_key_exists($sm_album_id, $album_count)) { $album_count[$sm_album_id] = 0; } if ($album_count[$sm_album_id] < $images_per_album && !$photos_seen[$thumb_url]) { $album_count[$sm_album_id]++; print "Downloading $sm_photo_id ... "; file_put_contents(dirname(__FILE__) . "/tmp.jpg", file_get_contents(str_replace('-Th', '-L', $thumb_url))); print "done\n"; print "Uploading $sm_photo_id ... "; $photo_ids[] = $uploader->upload(dirname(__FILE__) . "/tmp.jpg", $sm_photo_id, "I've recently uploaded images to my SmugMug account. Check them out."); print "done\n"; } $photos_seen[$thumb_url] = true; } if (count($photo_ids)) { printf("All done! If you care to make some changes:\n%s\n\n", $uploader->buildEditUrl($photo_ids)); } file_put_contents($photos_seen_log, serialize($photos_seen)); function get_photos_seen($photos_seen_log) { if (file_exists($photos_seen_log)) { $seen = unserialize(file_get_contents($photos_seen_log)); } return (is_array($seen)) ? $seen : array(); } function flickr_authenticate(&$flickr_api) { $flickr_frob = $flickr_api->requestFrob(); $flickr_auth_url = $flickr_api->buildAuthUrl('write', $flickr_frob); print "\nOpen the following URL and authorize:\n$flickr_auth_url\n"; print "\nPress return when you're finished...\n"; fgets(STDIN); $token = $flickr_api->setAuthTokenFromFrob($flickr_frob); $flickr_api->setAuthToken($token); } ?>