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.
#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;
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 87 guests