<?php

// Opakowuje żšdanie zdjęć z witryny Flickr
function getPhotos($callback,$format) {

   // Przygotowanie żšdania
   $base         = 'http://api.flickr.com/services/rest/';
   $query_string = '';

   $params = array( 'method'    => 'flickr.photos.search',
                 'api_key'   => '98dc95d53bbd454ad501591bbc53532a',
                 'user_id'   => '69562477@N00',
                 'format'    => $format
   );

   foreach ($params as $key => $value) {
      $query_string .= "$key=" . urlencode($value) . "&";
   }

   $url = "$base?$query_string";

   if (!empty($callback)) 
     $url = $url . 'jsoncallback=' . $callback;

   $rsp = file_get_contents($url);

   if ($format == 'php_serial') {
      $output = unserialize($rsp);
   } else {
      $output = $rsp;
   }

   return $output;
}

// Opakowuje żšdanie pobierajšce miejsce wykonania zdjęcia
function getLocation($callback,$format,$photo) {

   // Przygotowanie żšdania
   $base         = 'http://api.flickr.com/services/rest/';
   $query_string = '';

   $params = array( 'method'    => 'flickr.photos.geo.getLocation',
                 'api_key'   => '98dc95d53bbd454ad501591bbc53532a',
                 'photo_id'   => $photo,
                 'format'    => $format
   );

   foreach ($params as $key => $value) {
      $query_string .= "$key=" . urlencode($value) . "&";
   }

   $url = "$base?$query_string";

   if (!empty($callback))
     $url = $url . 'jsoncallback=' . $callback;

   $rsp = file_get_contents($url);

   if ($format == 'php_serial') {
      $output = unserialize($rsp);
   } else {
      $output = $rsp;
   }

   return $output;

}

// Opakowuje żšdanie pobierajšce oznaczenia zdjęcia
function getTags($callback, $format,$photo) {

   // Przygotowanie żšdania
   $base         = 'http://api.flickr.com/services/rest/';
   $query_string = '';

   $params = array( 'method'    => 'flickr.tags.getListPhoto',
                 'api_key'   => '98dc95d53bbd454ad501591bbc53532a',
                 'photo_id'   => $photo,
                 'format'    => $format,
                 'jsoncallback' => $callback
   );

   foreach ($params as $key => $value) {
      $query_string .= "$key=" . urlencode($value) . "&";
   }

   $url = "$base?$query_string";

   if (!empty($callback))
     $url = $url . 'jsoncallback=' . $callback;

   $rsp = file_get_contents($url);

   if ($format == 'php_serial') {
      $output = unserialize($rsp);
   } else {
      $output = $rsp;
   }

   return $output;

}
?>
