PHP Extension Fatturazione Elettronica Aruba IT: Create Transmission Request

Back to Index

Creazione di una nuova richiesta per la trasmissione di tipo “Comunicazioni Finanziarie” (invio richiesta file singolo).

Documentation: https://fatturazioneelettronica.aruba.it/apidoc/docs.html#_createtransmissionrequest

CURL Command

curl -X POST  https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequest?username=Utente&password=Password \
-H 'Accept: application/json' \
-H 'Content-Type: application/json;charset=UTF-8' \
-d '{
  "userName" : "Utente",
  "password" : "Password",
  "userID" : "Utente",
  "comunicationType" : "LI",
  "dataFile" : "dGVzdA=="
}'

PHP Extension Example

<?php

// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");

$rest = new CkRest();

//  URL: https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequest?username=Utente&password=Password
$bTls = true;
$port = 443;
$bAutoReconnect = true;
$success = $rest->Connect('testws.fatturazioneelettronica.aruba.it',$port,$bTls,$bAutoReconnect);
if ($success != true) {
    print 'ConnectFailReason: ' . $rest->get_ConnectFailReason() . "\n";
    print $rest->lastErrorText() . "\n";
    exit;
}

//  See the Online Tool for Generating JSON Creation Code
$json = new CkJsonObject();
$json->UpdateString('userName','Utente');
$json->UpdateString('password','Password');
$json->UpdateString('userID','Utente');
$json->UpdateString('comunicationType','LI');
$json->UpdateString('dataFile','dGVzdA==');

$rest->AddHeader('Content-Type','application/json;charset=UTF-8');
$rest->AddHeader('Accept','application/json');

$sbRequestBody = new CkStringBuilder();
$json->EmitSb($sbRequestBody);
$sbResponseBody = new CkStringBuilder();
$success = $rest->FullRequestSb('POST','/services/ClientRequest/CreateTransmissionRequest?username=Utente&password=Password',$sbRequestBody,$sbResponseBody);
if ($success != true) {
    print $rest->lastErrorText() . "\n";
    exit;
}

$respStatusCode = $rest->get_ResponseStatusCode();
if ($respStatusCode >= 400) {
    print 'Response Status Code = ' . $respStatusCode . "\n";
    print 'Response Header:' . "\n";
    print $rest->responseHeader() . "\n";
    print 'Response Body:' . "\n";
    print $sbResponseBody->getAsString() . "\n";
    exit;
}

$jsonResponse = new CkJsonObject();
$jsonResponse->LoadSb($sbResponseBody);

//  See the Online Tool for Generating JSON Parse Code

$errorCode = $jsonResponse->stringOf('errorCode');
$errorDescription = $jsonResponse->stringOf('errorDescription');
$requestID = $jsonResponse->stringOf('requestID');

?>

Sample JSON Response Body

{
  "errorCode": "",
  "errorDescription": "",
  "requestID": "XADI41PJUFSD3ZA7"
}