/** * Fetches all the Photos based on the userName and tag * * @params userName * - Name of the User whose photos have to be fetched * @params tag * - tag on which basis photos have to be fetched * * @return List of Album object containing all the Photos for the given * userName */ public function getTaggedPhotos($userName, $tag) { Util::throwExceptionIfNullOrBlank($userName, "User Name"); Util::throwExceptionIfNullOrBlank($tag, "Tag Name"); $encodedUserName = Util::encodeParams($userName); $encodedTag = Util::encodeParams($tag); $objUtil = new Util($this->apiKey, $this->secretKey); $albumList = array(); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['userName'] = $userName; $signParams['tag'] = $tag; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/tag/" . $encodedTag . "/userName/" . $encodedUserName; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $photoResponseObj = new AlbumResponseBuilder(); $albumList = $photoResponseObj->buildArrayResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $albumList; }
/** * Fetches all the Albums based on the userName * * @params userName * - The user for which the albums have to be fetched * * @return List of Album object containing all the album for the given * userName * * @throws App42Exception * */ function getAlbums($userName, $max = null, $offset = null) { $argv = func_get_args(); if (count($argv) == 1) { Util::throwExceptionIfNullOrBlank($userName, "User Name"); $encodedUserName = Util::encodeParams($userName); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['userName'] = $userName; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/album/" . $encodedUserName; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $albumResponseObj = new AlbumResponseBuilder(); $albumObj = $albumResponseObj->buildArrayResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $albumObj; } else { /** * Fetches all the Albums based on the userName by Paging. * * @params userName * - The user for which the albums have to be fetched * @params max * - Maximum number of records to be fetched * @params offset * - From where the records are to be fetched * * @return List of Album object containing all the album for the given * userName */ Util::throwExceptionIfNullOrBlank($userName, "User Name"); Util::throwExceptionIfNullOrBlank($max, "Max"); Util::throwExceptionIfNullOrBlank($offset, "Offset"); Util::validateMax($max); $encodedUserName = Util::encodeParams($userName); $encodedMax = Util::encodeParams($max); $encodedOffset = Util::encodeParams($offset); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['userName'] = $userName; $signParams['max'] = $max; $signParams['offset'] = $offset; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/album/" . $encodedUserName . "/" . $encodedMax . "/" . $encodedOffset; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $albumResponseObj = new AlbumResponseBuilder(); $albumObj = $albumResponseObj->buildArrayResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $albumObj; } }