Search
 
SCRIPT & CODE EXAMPLE
 

PHP

api anaf

// Official documentation: 
// 1) https://static.anaf.ro/static/10/Anaf/Informatii_R/doc_WS_Async_V6.txt
// 2) https://static.anaf.ro/static/10/Anaf/Informatii_R/doc_WS_V6.txt

// PHP curl example
// set payload for single request
$payload = [
    "cui"=> $data['cui'],  // "14399840"
    "data"=> $data['date'] // "2022-05-02"
];
// or for multiple requests
$payload = [
    [
        "cui"=> $data['cui'],  // "14399840"
        "data"=> $data['date'] // "2022-05-02"
    ],
    [
        "cui"=> $data['cui'],  // "14399841"
        "data"=> $data['date'] // "2022-05-02"
    ]
];
	
// Anaf server can handle up to 500 different cuis per request
// Never do more than 1 request per seccond
// initialize curl object
$curl = curl_init();
// set curl object
curl_setopt_array( $curl, array(
    CURLOPT_URL => 'https://webservicesp.anaf.ro/PlatitorTvaRest/api/v6/ws/tva',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => json_encode( [ $payload ] ),
    CURLOPT_HTTPHEADER => array( 'Content-type: application/json' ),
) );
// set result
$result = curl_exec( $curl );
// set http code
$statusCode = ( int ) curl_getinfo( $curl, CURLINFO_HTTP_CODE );
// close connection
curl_close( $curl );
// convert the response from json to object
$response = ( array ) json_decode( $result, true );
Comment

PREVIOUS NEXT
Code Example
Php :: Target class [Controller] does not exist. 
Php :: make model and migration in laravel 
Php :: magento 2 print php error 
Php :: run a server php terminal 
Php :: php needle haystack 
Php :: return response not found laravel api response 
Php :: how to save file in storage folder in laravel 
Php :: acf wp_query custom field 
Php :: how to add property to an exsisting object in php 
Php :: How can I get current controller and current controller action name in yii2 
Php :: how to replace double quotes in a string in php 
Php :: get current url in controller in laravel 
Php :: pass javascriot value from one page to another 
Php :: how to display user id from a function on a wordpress page 
Php :: if condition inside echo in php 
Php :: laravel model casts 
Php :: ubuntu install php 8 mysql 
Php :: installing apache mod php 
Php :: blade condition if else laravel 
Php :: how to build jquery messages notification with php and mysq 
Php :: validate each value from array laravel 
Php :: flutter network image svg 
Php :: wordpress programmatically logout 
Php :: php float round 
Php :: php send telegram message to user 
Php :: 18 year back date in php 
Php :: laravel ckeditor 
Php :: get month first date and last date in php 
Php :: php get keys and values from array 
Php :: php year from date 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =