/* interesting.php: Creates an RSS feed of the flickr interesting photos. Copyright (C) 2008 Sean P. Reiser This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The GNU Public LIcense is available here: http://www.gnu.org/licenses/. */ /* uses phpFlickr available at http://phpflickr.com */ '); fwriteln ($output,''); fwriteln($output,''); fwriteln($output,''); fwriteln($output,'Flickr Interesting Photos'); fwriteln($output,'http://www.flickr.com/explore/interesting/'); fwriteln($output,'Flickr Photo Ranked with a high degree of Interestingness'); fwriteln($output,'en-us'); $f = new phpFlickr("46bd1f1ba972791627e4ad0d58ab4f96"); // Search for most interesting photos of today $photos_interesting = $f->interestingness_getList(NULL, NULL, 50); foreach ($photos_interesting['photo'] as $photo){ fwriteln($output,""); if (empty($photo['title'])){ $title = "No Title on Flickr"; } else{ $title = $photo['title']; } fwriteln($output,"".htmlspecialchars($title).""); fwriteln($output,"http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'] . "/"); fwriteln($output,"http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'] . "/"); fwriteln($output,"".htmlspecialchars($title).""); $temp = $f->photos_getSizes($photo['id']); $n = count($temp); $hrurl = $temp[$n-1]['source']; $extension = substr($hrurl,strrpos($hrurl,'.')+1); switch ($extension){ case "jpg": case "jpeg": case "jpe": case "jfif": case "pjpeg": case "pjp": $mimetype = "image/jpeg"; break; case "png": $mimetype = "image/png"; break; case "gif": $mimetype = "image/gif"; break; case "bmp": $mimetype = "image/bmp"; break; } fwriteln($output,''); fwriteln($output,""); } fwriteln($output,''); fwriteln($output,''); fclose($output); function getHRUrl($item) { $ch = curl_init($item->link); $input = fopen("temp.html", "w"); $continue = true; $output = "not Found"; $nCtr = 0; curl_setopt($ch, CURLOPT_FILE, $input); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($input); $buffer= file_get_contents("temp.html",FILE_BINARY); $pos = strpos(strtoupper($buffer),'IMG'); if ($pos > 0) { $temp = substr($buffer,$pos-60,100); $tmp2 = strpos($temp,"a href"); $temp = substr($temp,$tmp2+7,100); $end = strpos($temp,'IMG') - 5; $output = substr($temp,1, $end); } return "http://apod.nasa.gov/apod/".$output; } function fwriteln($output,$String){ fwrite($output,$String."\r\n"); } function getrss($SourceFile,$TargetFile) { $ch = curl_init($SourceFile); $input = fopen($TargetFile, "w"); curl_setopt($ch, CURLOPT_FILE, $input); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($input); } ?>