false]); $request = new Request( // PUT! 'PUT', // predefined url $feedUploadUrl, // content type equal to content type from response createFeedDocument-operation array('Content-Type' => $contentType), // resource File $file_content ); $response = $client->send($request); $HTTPStatusCode = $response->getStatusCode(); if ($HTTPStatusCode == 200) { return 'Done'; } else { return $response->getBody()->getContents(); } } /** * @param $payload : Response from getFeedDocument Function. e.g.: response['payload'] * @return array : Feed Processing Report. */ public function downloadFeedProcessingReport($payload) { $key = null; $initializationVector = null; $feedUploadUrl = $payload['url']; // check if decryption in required if (isset($payload['encryptionDetails'])) { $key = $payload['encryptionDetails']['key']; $initializationVector = $payload['encryptionDetails']['initializationVector']; // base64 decode before using in encryption $initializationVector = base64_decode($initializationVector, true); $key = base64_decode($key, true); } $feedDownloadUrl = $payload['url']; if (!is_null($key)) { $feed_processing_report_content = ASECryptoStream::decrypt(file_get_contents($feedDownloadUrl), $key, $initializationVector); } else { $feed_processing_report_content = file_get_contents($feedDownloadUrl); } if(isset($payload['compressionAlgorithm']) && $payload['compressionAlgorithm']=='GZIP') { $feed_processing_report_content = gzdecode($feed_processing_report_content); } // check if report content is json encoded or not if ($this->isJson($feed_processing_report_content) == true) { $json = $feed_processing_report_content; } else { $feed_processing_report_content = preg_replace('/\s+/S', " ", $feed_processing_report_content); $xml = simplexml_load_string($feed_processing_report_content); $json = json_encode($xml); } return json_decode($json, TRUE); } public function isJson($string) { json_decode($string); return json_last_error() === JSON_ERROR_NONE; } }