function updatePhoto($userName, $albumName, $photoName, $photoDescription, $path) { Util::throwExceptionIfNullOrBlank($userName, "User Name"); Util::throwExceptionIfNullOrBlank($albumName, "Album Name"); Util::throwExceptionIfNullOrBlank($photoName, "Photo Name"); Util::throwExceptionIfNullOrBlank($photoDescription, "Description"); Util::throwExceptionIfNullOrBlank($path, "Path"); Util::throwExceptionIfNotValidImageExtension($path, "Photo Path"); $encodedUserName = Util::encodeParams($userName); $objUtil = new Util($this->apiKey, $this->secretKey); if (!file_exists($path)) { throw new App42Exception("File Not Found"); } try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $postParams = array(); $postParams['userName'] = $userName; $postParams['albumName'] = $albumName; $postParams['name'] = $photoName; $postParams['description'] = $photoDescription; $params = array_merge($postParams, $signParams); $signature = urlencode($objUtil->sign($params)); //die(); $params['imageFile'] = "@" . $path; $headerParams['signature'] = $signature; $contentType = "multipart/form-data"; $body = null; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/update/" . $encodedUserName; $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $photoResponseObj = new AlbumResponseBuilder(); $photoObj = $photoResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $photoObj; }
/** * Fetch all Albums based on userName and albumName * * @params userName * - The user for which the album has to be fetched * @params albumName * - Name of the album that has to be fetched * * @return Album object containing album information for the given userName * and albumName */ function getAlbumByName($userName, $albumName) { Util::throwExceptionIfNullOrBlank($userName, "User Name"); Util::throwExceptionIfNullOrBlank($albumName, "Album Name"); $encodedUserName = Util::encodeParams($userName); $encodedAlbumName = Util::encodeParams($albumName); $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['albumName'] = $albumName; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/album/" . $encodedUserName . "/" . $encodedAlbumName; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $albumResponseObj = new AlbumResponseBuilder(); $albumObj = $albumResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $albumObj; }