30000000) { $returnObject = new stdClass(); $returnObject->code = 1; $returnObject->error = 1; $returnObject->retval = 'File to big'; return $returnObject; } // Get the content of the given file $inputFileContent = file_get_contents($inputFileName); if ($inputFileContent === false) // if failed { error_log('An error occurred while getting the content from: '.$inputFileName); } else { // Posts the given file content + file name and expects a response in JSON format $resultPost = \Httpful\Request::post(SIGNATUR_URL.'/'.SIGNATUR_LIST_API) ->sendsJson() ->authenticateWith(SIGNATUR_USER, SIGNATUR_PASSWORD) ->body('{"filename": "'.basename($inputFileName).'", "content": "'.base64_encode($inputFileContent).'"}') ->expectsJson() ->send(); } } catch(\Httpful\Exception\ConnectionErrorException $cee) // Httpful exception { error_log($cee->getMessage()); } catch (Exception $e) // any other exception { error_log($e->getMessage()); } // If the response is fine if (isset($resultPost->body) && is_object($resultPost->body) && isset($resultPost->body->retval) && is_array($resultPost->body->retval)) { return $resultPost->body->retval; } // Otherwise return a null as error return null; } }