VIES check 2023

VIES check 2023

Postby Marc Venken » Thu Aug 10, 2023 7:32 am

Has anyone, hoping for a Belgium forum member connected to the VIES system in order to retrieve data from the VIES system by the VAT-number ?

Early postings seems to be outdated with the connections made at that time.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: VIES check 2023

Postby Antonio Linares » Thu Aug 10, 2023 7:47 am

Dear Marc,

chatgpt response, not sure if it may help:
Code: Select all  Expand view
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>

// Callback function to receive HTTP response data
size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) {
    size_t realsize = size * nmemb;
    char *response = (char *)userp;

    // Append the received data to the response buffer
    memcpy(response, contents, realsize);
    return realsize;
}

int main(void) {
    CURL *curl;
    CURLcode res;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if (curl) {
        char url[200];  // Adjust buffer size if necessary
        char vatNumber[20];  // The VAT number you want to check
        char responseBuffer[1024];  // Buffer to store the response data

        // Construct the URL for VIES VAT number validation
        sprintf(url, "http://ec.europa.eu/taxation_customs/vies/vatResponse.html?&memberStateCode=&number=%s&traderName=&traderCompanyType=&traderStreet=&traderPostcode=&traderCity=&requesterMemberStateCode=&requesterNumber=&action=check&check=Verify",
                vatNumber);

        // Set the URL
        curl_easy_setopt(curl, CURLOPT_URL, url);

        // Set the write callback function to handle the response data
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, responseBuffer);

        // Perform the HTTP request
        res = curl_easy_perform(curl);

        if (res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        } else {
            // Print the received response
            printf("Response:\n%s\n", responseBuffer);
        }

        // Cleanup
        curl_easy_cleanup(curl);
    }

    curl_global_cleanup();
    return 0;
}
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests