PHP Extension Fatturazione Elettronica Aruba IT: Create Transmission Request List

Back to Index

Creazione richiesta di trasmissione “Comunicazioni Finanziarie” in formato zip.

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

CURL Command

curl -X POST  https://testws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequestList?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/CreateTransmissionRequestList?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/CreateTransmissionRequestList?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');
$i = 0;
$count_i = $jsonResponse->SizeOfArray('requestIDList');
while ($i < $count_i) {
    $jsonResponse->put_I($i);
    $fileName = $jsonResponse->stringOf('requestIDList[i].fileName');
    $requestID = $jsonResponse->stringOf('requestIDList[i].requestID');
    $i = $i + 1;
}


?>

Sample JSON Response Body

{
  "errorCode": "",
  "errorDescription": "",
  "requestID": "YWWCED5QWHU7AQGL",
  "requestIDList": [
    {
      "fileName": "ITADFSREETDSD_LI_0001.xml",
      "requestID": "4LMW5CCCBLXKS522"
    },
    {
      "fileName": "ITADFSREETDSD_LI_0002.xml",
      "requestID": "62LXGBLXJCDEAX3M"
    },
    {
      "fileName": "ITADFSREETDSD_LI_0003.xml",
      "requestID": "GBJDXIYJSWMRKQBP"
    }
  ]
}